mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
lazy: add setupOpts support
This commit is contained in:
parent
23c6f319cd
commit
659c4b5ca2
2 changed files with 34 additions and 3 deletions
|
@ -65,10 +65,27 @@
|
||||||
# type= str;
|
# type= str;
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
# Non-lz.n options
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = pluginType;
|
type = pluginType;
|
||||||
|
description = "Plugin package";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setupModule = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Lua module to run setup function on.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
setupOpts = mkOption {
|
||||||
|
type = submodule {freeformType = attrsOf anything;};
|
||||||
|
description = "Options to pass to the setup function";
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
# lz.n options
|
||||||
|
|
||||||
before = mkOption {
|
before = mkOption {
|
||||||
type = nullOr luaInline;
|
type = nullOr luaInline;
|
||||||
description = "Code to run before plugin is loaded";
|
description = "Code to run before plugin is loaded";
|
||||||
|
|
|
@ -3,15 +3,29 @@
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
inherit (builtins) toJSON;
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.attrsets) mapAttrsToList;
|
inherit (lib.attrsets) mapAttrsToList;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
cfg = config.vim.lazy;
|
cfg = config.vim.lazy;
|
||||||
|
|
||||||
toLuaLznSpec = name: plugin:
|
toLuaLznSpec = name: spec:
|
||||||
(removeAttrs plugin ["package"])
|
(removeAttrs spec ["package" "setupModule" "setupOpts"])
|
||||||
// {"@1" = name;};
|
// {
|
||||||
|
"@1" = name;
|
||||||
|
after = mkLuaInline ''
|
||||||
|
function()
|
||||||
|
${
|
||||||
|
optionalString (spec.setupModule != null)
|
||||||
|
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"
|
||||||
|
}
|
||||||
|
${optionalString (spec.after != null) spec.after}
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
};
|
||||||
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
|
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
|
||||||
in {
|
in {
|
||||||
config.vim = mkIf cfg.enable {
|
config.vim = mkIf cfg.enable {
|
||||||
|
|
Loading…
Reference in a new issue