mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-22 08:53:28 +02:00
modules: refactor plugins code in top-level
This commit is contained in:
parent
d81f37256d
commit
efb24d78bd
7 changed files with 221 additions and 122 deletions
38
modules/top-level/plugins/utils.nix
Normal file
38
modules/top-level/plugins/utils.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
lib:
|
||||
lib.fix (self: {
|
||||
normalizedPluginType = lib.types.submodule {
|
||||
options = {
|
||||
plugin = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
};
|
||||
|
||||
config = lib.mkOption {
|
||||
type = with lib.types; nullOr str;
|
||||
};
|
||||
|
||||
optional = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Normalize a plugin in a standard { plugin, config, optional } attrs
|
||||
normalizePlugin =
|
||||
p:
|
||||
let
|
||||
defaultPlugin = {
|
||||
plugin = null;
|
||||
config = null;
|
||||
optional = false;
|
||||
};
|
||||
in
|
||||
defaultPlugin // (if p ? plugin then p else { plugin = p; });
|
||||
|
||||
# Normalize a list of plugins
|
||||
normalizePlugins = builtins.map self.normalizePlugin;
|
||||
|
||||
getAndNormalizeDeps = p: self.normalizePlugins (p.plugin.dependencies or [ ]);
|
||||
|
||||
# Remove dependencies from all plugins in a list
|
||||
removeDeps = map (p: p // { plugin = removeAttrs p.plugin [ "dependencies" ]; });
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue