lib/plugins/mk{Neovim,Vim}Plugin: add dependencies parameter

This commit is contained in:
Gaetan Lepage 2025-04-27 09:13:33 +02:00
parent 89c94d9ea7
commit b66559d8ef
4 changed files with 24 additions and 0 deletions

View file

@ -27,6 +27,8 @@
# - An option will be used as-is, but should be built using `lib.mkPackageOption`
# Defaults to `name`, i.e. `pkgs.vimPlugins.${name}`
package ? name,
# Which dependencies to enable by default
dependencies ? [ ],
settingsOptions ? { },
settingsExample ? null,
settingsDescription ? "Options provided to the `require('${moduleName}')${setup}` function.",
@ -105,6 +107,8 @@ let
}
))
(lib.nixvim.plugins.utils.enableDependencies dependencies)
# When lazy loading is enabled for this plugin, route its configuration to the enabled provider
(lib.mkIf cfg.lazyLoad.enable {
assertions = [

View file

@ -22,6 +22,8 @@
# - An option will be used as-is, but should be built using `lib.mkPackageOption`
# Defaults to `name`, i.e. `pkgs.vimPlugins.${name}`
package ? name,
# Which dependencies to enable by default
dependencies ? [ ],
settingsOptions ? { },
settingsExample ? null,
globalPrefix ? "",
@ -78,6 +80,7 @@ let
inherit extraConfig cfg opts;
}
))
(lib.nixvim.plugins.utils.enableDependencies dependencies)
]
);
};

View file

@ -111,4 +111,18 @@
};
};
};
enableDependencies = depsToEnable: {
dependencies =
let
enableDepConditionally = dep: {
name = dep.name or dep;
value.enable = lib.mkIf (dep.enable or true) (lib.mkDefault true);
};
in
lib.pipe depsToEnable [
(builtins.map enableDepConditionally)
lib.listToAttrs
];
};
}