mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-25 10:18:36 +02:00
lib/neovim-plugin: support lazy loading luaConfig.content
This commit is contained in:
parent
2e30f4828d
commit
301868d380
2 changed files with 59 additions and 1 deletions
|
@ -113,6 +113,30 @@
|
||||||
'';
|
'';
|
||||||
internal = true;
|
internal = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lazyLoad = lib.mkOption {
|
||||||
|
default = {
|
||||||
|
enable = false;
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Lazy load configuration settings.
|
||||||
|
'';
|
||||||
|
type = lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
enable = lib.mkOption {
|
||||||
|
default = false;
|
||||||
|
type = lib.types.bool;
|
||||||
|
description = ''
|
||||||
|
Whether to lazy load the plugin.
|
||||||
|
|
||||||
|
If you enable this, the plugin's lua configuration will need to be manually loaded by other means.
|
||||||
|
|
||||||
|
A usage would be passing the plugin's luaConfig to the `plugins.lz-n.plugins` configuration.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs hasSettings {
|
// lib.optionalAttrs hasSettings {
|
||||||
settings = lib.nixvim.mkSettingsOption {
|
settings = lib.nixvim.mkSettingsOption {
|
||||||
|
@ -162,7 +186,7 @@
|
||||||
(lib.optionalAttrs callSetup { ${namespace}.${name}.luaConfig.content = setupCode; })
|
(lib.optionalAttrs callSetup { ${namespace}.${name}.luaConfig.content = setupCode; })
|
||||||
|
|
||||||
# Write the lua configuration `luaConfig.content` to the config file
|
# Write the lua configuration `luaConfig.content` to the config file
|
||||||
(setLuaConfig cfg.luaConfig.content)
|
(lib.mkIf (!cfg.lazyLoad.enable) (setLuaConfig cfg.luaConfig.content))
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
34
tests/test-sources/plugins/lazy-load.nix
Normal file
34
tests/test-sources/plugins/lazy-load.nix
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
lazy-load-plugin =
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
plugins = {
|
||||||
|
lz-n = {
|
||||||
|
enable = true;
|
||||||
|
plugins = [
|
||||||
|
{
|
||||||
|
__unkeyed-1 = "neotest";
|
||||||
|
after.__raw = ''
|
||||||
|
function()
|
||||||
|
${config.plugins.neotest.luaConfig.content}
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
keys = [
|
||||||
|
{
|
||||||
|
__unkeyed-1 = "<leader>nt";
|
||||||
|
__unkeyed-3 = "<CMD>Neotest summary<CR>";
|
||||||
|
desc = "Summary toggle";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
neotest = {
|
||||||
|
enable = true;
|
||||||
|
lazyLoad.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue