mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-12-14 16:11:03 +00:00
lazy: support lazy.enable=false
This commit is contained in:
parent
f3a41aa2b4
commit
283ea5b92c
1 changed files with 40 additions and 10 deletions
|
|
@ -3,12 +3,12 @@
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) toJSON typeOf head length tryEval filter;
|
inherit (builtins) toJSON typeOf head length tryEval filter concatLists concatStringsSep;
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (lib.nvim.dag) entryBefore;
|
inherit (lib.nvim.dag) entryBefore entryAfter;
|
||||||
cfg = config.vim.lazy;
|
cfg = config.vim.lazy;
|
||||||
|
|
||||||
toLuaLznKeySpec = keySpec:
|
toLuaLznKeySpec = keySpec:
|
||||||
|
|
@ -63,8 +63,27 @@
|
||||||
else spec.keys;
|
else spec.keys;
|
||||||
};
|
};
|
||||||
lznSpecs = map toLuaLznSpec cfg.plugins;
|
lznSpecs = map toLuaLznSpec cfg.plugins;
|
||||||
|
|
||||||
|
specToNotLazyConfig = spec: ''
|
||||||
|
do
|
||||||
|
${optionalString (spec.before != null) spec.before}
|
||||||
|
${optionalString (spec.setupModule != null)
|
||||||
|
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"}
|
||||||
|
${optionalString (spec.after != null) spec.after}
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
|
||||||
|
specToKeymaps = spec:
|
||||||
|
if typeOf spec.keys == "list"
|
||||||
|
then map (x: removeAttrs x ["ft"]) (filter (lznKey: lznKey.action != null && lznKey.ft == null) spec.keys)
|
||||||
|
else if spec.keys == null || typeOf spec.keys == "string"
|
||||||
|
then []
|
||||||
|
else [spec.keys];
|
||||||
|
|
||||||
|
notLazyConfig = concatStringsSep "\n" (map specToNotLazyConfig cfg.plugins);
|
||||||
in {
|
in {
|
||||||
config.vim = mkIf cfg.enable {
|
config.vim = mkMerge [
|
||||||
|
(mkIf cfg.enable {
|
||||||
startPlugins = ["lz-n" "lzn-auto-require"];
|
startPlugins = ["lz-n" "lzn-auto-require"];
|
||||||
|
|
||||||
optPlugins = map (plugin: plugin.package) cfg.plugins;
|
optPlugins = map (plugin: plugin.package) cfg.plugins;
|
||||||
|
|
@ -72,5 +91,16 @@ in {
|
||||||
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] ''
|
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] ''
|
||||||
require('lz.n').load(${toLuaObject lznSpecs})
|
require('lz.n').load(${toLuaObject lznSpecs})
|
||||||
'';
|
'';
|
||||||
};
|
})
|
||||||
|
(
|
||||||
|
mkIf (!cfg.enable) {
|
||||||
|
startPlugins = map (plugin: plugin.package) cfg.plugins;
|
||||||
|
luaConfigPre =
|
||||||
|
concatStringsSep "\n"
|
||||||
|
(filter (x: x != null) (map (spec: spec.beforeAll) cfg.plugins));
|
||||||
|
luaConfigRC.unlazy = entryAfter ["pluginConfigs"] notLazyConfig;
|
||||||
|
keymaps = concatLists (map specToKeymaps cfg.plugins);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue