lib/neovim-plugin: support lz-n lazy config

This commit is contained in:
Austin Horstman 2024-12-02 12:23:45 -06:00
parent da30527de1
commit 3cfde1554c
No known key found for this signature in database
3 changed files with 155 additions and 23 deletions

View file

@ -116,9 +116,9 @@
lazyLoad = lib.nixvim.mkLazyLoadOption {
inherit originalName;
lazyLoadDefaults = (
lib.optionalAttrs (isColorscheme && colorscheme != null) { inherit colorscheme; }
);
lazyLoadDefaults = lib.optionalAttrs (isColorscheme && colorscheme != null) {
inherit colorscheme;
};
};
}
// lib.optionalAttrs hasSettings {
@ -171,6 +171,34 @@
# Write the lua configuration `luaConfig.content` to the config file
(lib.mkIf (!cfg.lazyLoad.enable) (setLuaConfig cfg.luaConfig.content))
])
++ (lib.optionals hasConfigAttrs [
(lib.mkIf (cfg.lazyLoad.backend == "lz.n") {
plugins.lz-n = {
# infinite recursion?
# enable = true;
plugins = [
{
# TODO: handle this for every plugin properly
__unkeyed-1 = originalName;
# Use provided after, otherwise fallback to normal lua content
after = if cfg.lazyLoad.after != null then cfg.lazyLoad.after else cfg.luaConfig.content;
inherit (cfg.lazyLoad)
enabled
priority
before
beforeAll
event
cmd
ft
keys
colorscheme
extraSettings
;
}
];
};
})
])
)
);
};

View file

@ -360,6 +360,15 @@ rec {
lazy-loading for ${originalName}
'';
backend =
mkEnumFirstDefault
[
"lz.n"
]
''
The lazy-loading backend to use.
'';
# Spec loading:
enabled = mkStrLuaFnOr types.bool (lazyLoadDefaults.enabledInSpec or null) ''
When false, or if the function returns false, then ${originalName} will not be included in the spec.