mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-21 10:58:01 +00:00
refactor: re-order plugin and lz.n configs
lazy: make lzn-auto-require togglable
This commit is contained in:
parent
eb95f77e75
commit
192340494b
3 changed files with 34 additions and 10 deletions
|
@ -76,7 +76,13 @@
|
||||||
then []
|
then []
|
||||||
else [spec.keys];
|
else [spec.keys];
|
||||||
|
|
||||||
notLazyConfig = concatStringsSep "\n" (mapAttrsToList specToNotLazyConfig cfg.plugins);
|
notLazyConfig =
|
||||||
|
concatStringsSep "\n"
|
||||||
|
(mapAttrsToList specToNotLazyConfig cfg.plugins);
|
||||||
|
|
||||||
|
beforeAllJoined =
|
||||||
|
concatStringsSep "\n"
|
||||||
|
(filter (x: x != null) (mapAttrsToList (_: spec: spec.beforeAll) cfg.plugins));
|
||||||
in {
|
in {
|
||||||
config.vim = mkMerge [
|
config.vim = mkMerge [
|
||||||
(mkIf cfg.enable {
|
(mkIf cfg.enable {
|
||||||
|
@ -84,17 +90,18 @@ in {
|
||||||
|
|
||||||
optPlugins = pluginPackages;
|
optPlugins = pluginPackages;
|
||||||
|
|
||||||
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] ''
|
lazy.builtLazyConfig = ''
|
||||||
require('lz.n').load(${toLuaObject lznSpecs})
|
require('lz.n').load(${toLuaObject lznSpecs})
|
||||||
|
${optionalString cfg.enableLznAutoRequire "require('lzn-auto-require').enable()"}
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf (!cfg.enable) {
|
(mkIf (!cfg.enable) {
|
||||||
startPlugins = pluginPackages;
|
startPlugins = pluginPackages;
|
||||||
luaConfigPre =
|
lazy.builtLazyConfig = ''
|
||||||
concatStringsSep "\n"
|
${beforeAllJoined}
|
||||||
(filter (x: x != null) (mapAttrsToList (_: spec: spec.beforeAll) cfg.plugins));
|
${notLazyConfig}
|
||||||
luaConfigRC.unlazy = entryAfter ["pluginConfigs"] notLazyConfig;
|
'';
|
||||||
keymaps = concatLists (mapAttrsToList specToKeymaps cfg.plugins);
|
keymaps = concatLists (mapAttrsToList specToKeymaps cfg.plugins);
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
|
@ -181,7 +181,7 @@
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
options.vim.lazy = {
|
options.vim.lazy = {
|
||||||
enable = mkEnableOption "plugin lazy-loading" // {default = true;};
|
enable = mkEnableOption "plugin lazy-loading via lz.n and lzn-auto-require" // {default = true;};
|
||||||
loader = mkOption {
|
loader = mkOption {
|
||||||
description = "Lazy loader to use";
|
description = "Lazy loader to use";
|
||||||
type = enum ["lz.n"];
|
type = enum ["lz.n"];
|
||||||
|
@ -215,5 +215,23 @@ in {
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enableLznAutoRequire = mkOption {
|
||||||
|
description = ''
|
||||||
|
Enable lzn-auto-require. Since builtin plugins rely on this, only turn
|
||||||
|
off for debugging.
|
||||||
|
'';
|
||||||
|
type = bool;
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
builtLazyConfig = mkOption {
|
||||||
|
internal = true;
|
||||||
|
type = lines;
|
||||||
|
description = ''
|
||||||
|
The built config for lz.n, or if `vim.lazy.enable` is false, the
|
||||||
|
individual plugin configs.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,11 +52,10 @@ in {
|
||||||
optionsScript = entryAfter ["basic"] (concatLines optionsScript);
|
optionsScript = entryAfter ["basic"] (concatLines optionsScript);
|
||||||
|
|
||||||
# Basic
|
# Basic
|
||||||
pluginConfigs = entryAfter ["optionsScript"] pluginConfigs;
|
lazyConfigs = entryAfter ["optionsScript"] cfg.lazy.builtLazyConfig;
|
||||||
|
pluginConfigs = entryAfter ["lazyConfigs"] pluginConfigs;
|
||||||
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
|
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
|
||||||
mappings = entryAfter ["extraPluginConfigs"] keymaps;
|
mappings = entryAfter ["extraPluginConfigs"] keymaps;
|
||||||
# FIXME: put this somewhere less stupid
|
|
||||||
footer = entryAfter ["mappings"] (optionalString config.vim.lazy.enable "require('lzn-auto-require').enable()");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
builtLuaConfigRC = let
|
builtLuaConfigRC = let
|
||||||
|
|
Loading…
Add table
Reference in a new issue