mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
lib/plugins/mk{Neovim,Vim}Plugin: add dependencies parameter
This commit is contained in:
parent
89c94d9ea7
commit
b66559d8ef
4 changed files with 24 additions and 0 deletions
|
@ -63,6 +63,7 @@ A template plugin can be found in (plugins/TEMPLATE.nix)[https://github.com/nix-
|
|||
| **callSetup** | Indicating whether to call the setup function. Useful when `setup` function needs customizations. | No | `true` |
|
||||
| **colorscheme** | The name of the colorscheme. | No | `name` parameter |
|
||||
| **configLocation** | The option location where the lua configuration should be installed. Nested option locations can be represented as a list. The location can also be wrapped using `lib.mkBefore`, `lib.mkAfter`, or `lib.mkOrder`. | No | `"extraConfigLuaPre"` if `isColorscheme` then `extraConfigLuaPre`, otherwise `"extraConfigLua"` |
|
||||
| **dependencies** | A list of [`dependencies`] to enable by default with this plugin. (List of strings) | No | `[]` |
|
||||
| **deprecateExtraOptions** | Indicating whether to deprecate the `extraOptions` attribute. Mainly used for old plugins. | No | `false` |
|
||||
| **description** | A brief description of the plugin. Can also be used for non-normative documentation, warnings, tips and tricks. | No | `null` |
|
||||
| **extraConfig** | Additional configuration for the plugin. Either an attrset, a function accepting `cfg`, or a function accepting `cfg` and `opts`. | No | `{}` |
|
||||
|
@ -126,6 +127,7 @@ Such plugins are usually configured via vim globals, but often have no configura
|
|||
| **name** | The name of the Vim plugin. | Yes | N/A |
|
||||
| **url** | The URL of the plugin repository. | Yes | `package` parameter's `meta.homepage` |
|
||||
| **colorscheme** | The name of the colorscheme. | No | `name` parameter |
|
||||
| **dependencies** | A list of [`dependencies`] to enable by default with this plugin. (List of strings) | No | `[]` |
|
||||
| **deprecateExtraConfig** | Flag to deprecate extra configuration. | No | `false` |
|
||||
| **description** | A description of the plugin. Can also be used for non-normative documentation, warnings, tips and tricks. | No | `null` |
|
||||
| **extraConfig** | Extra configuration for the plugin. Either an attrset, a function accepting `cfg`, or a function accepting `cfg` and `opts`. | No | `{}` |
|
||||
|
@ -316,3 +318,4 @@ considerably. To use it, just install cachix and run `cachix use nix-community`.
|
|||
[`mkNeovimPlugin`]: #mkneovimplugin
|
||||
[Writing option examples]: #writing-option-examples
|
||||
[Declaring plugin options]: #declaring-plugin-options
|
||||
[`dependencies`]: https://nix-community.github.io/nixvim/dependencies/bat.html
|
||||
|
|
|
@ -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 = [
|
||||
|
|
|
@ -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)
|
||||
]
|
||||
);
|
||||
};
|
||||
|
|
|
@ -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
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue