mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-20 02:18:06 +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 []
|
||||
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 {
|
||||
config.vim = mkMerge [
|
||||
(mkIf cfg.enable {
|
||||
|
@ -84,17 +90,18 @@ in {
|
|||
|
||||
optPlugins = pluginPackages;
|
||||
|
||||
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] ''
|
||||
lazy.builtLazyConfig = ''
|
||||
require('lz.n').load(${toLuaObject lznSpecs})
|
||||
${optionalString cfg.enableLznAutoRequire "require('lzn-auto-require').enable()"}
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf (!cfg.enable) {
|
||||
startPlugins = pluginPackages;
|
||||
luaConfigPre =
|
||||
concatStringsSep "\n"
|
||||
(filter (x: x != null) (mapAttrsToList (_: spec: spec.beforeAll) cfg.plugins));
|
||||
luaConfigRC.unlazy = entryAfter ["pluginConfigs"] notLazyConfig;
|
||||
lazy.builtLazyConfig = ''
|
||||
${beforeAllJoined}
|
||||
${notLazyConfig}
|
||||
'';
|
||||
keymaps = concatLists (mapAttrsToList specToKeymaps cfg.plugins);
|
||||
})
|
||||
];
|
||||
|
|
|
@ -181,7 +181,7 @@
|
|||
};
|
||||
in {
|
||||
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 {
|
||||
description = "Lazy loader to use";
|
||||
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);
|
||||
|
||||
# Basic
|
||||
pluginConfigs = entryAfter ["optionsScript"] pluginConfigs;
|
||||
lazyConfigs = entryAfter ["optionsScript"] cfg.lazy.builtLazyConfig;
|
||||
pluginConfigs = entryAfter ["lazyConfigs"] pluginConfigs;
|
||||
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue