mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-27 11:08:53 +02:00
helpers/mkPlugin: add extraConfig option
This commit is contained in:
parent
563ab0660b
commit
97fb6d6a29
3 changed files with 39 additions and 7 deletions
|
@ -322,16 +322,27 @@ with lib; rec {
|
|||
...
|
||||
}: let
|
||||
cfg = config.plugins.${name};
|
||||
|
||||
description =
|
||||
if description is null
|
||||
then name
|
||||
else description;
|
||||
|
||||
# TODO support nested options!
|
||||
pluginOptions = mapAttrs (k: v: v.option) options;
|
||||
pluginOptions =
|
||||
mapAttrs
|
||||
(
|
||||
optName: opt:
|
||||
opt.option
|
||||
)
|
||||
options;
|
||||
globals =
|
||||
mapAttrs'
|
||||
(name: opt: {
|
||||
(optName: opt: {
|
||||
name = globalPrefix + opt.global;
|
||||
value =
|
||||
if cfg.${name} != null
|
||||
then opt.value cfg.${name}
|
||||
else null;
|
||||
ifNonNull' cfg.${optName}
|
||||
(opt.value cfg.${optName});
|
||||
})
|
||||
options;
|
||||
# does this evaluate package?
|
||||
|
@ -341,11 +352,31 @@ with lib; rec {
|
|||
else {
|
||||
package = mkPackageOption name package;
|
||||
};
|
||||
|
||||
extraConfigOption =
|
||||
if (isString globalPrefix) && (globalPrefix != "")
|
||||
then {
|
||||
extraConfig = mkOption {
|
||||
type = with types; attrsOf anything;
|
||||
description = ''
|
||||
The configuration options for ${name} without the '${globalPrefix}' prefix.
|
||||
Example: To set '${globalPrefix}_foo_bar' to 1, write
|
||||
```nix
|
||||
extraConfig = {
|
||||
foo_bar = true;
|
||||
};
|
||||
```
|
||||
'';
|
||||
default = {};
|
||||
};
|
||||
}
|
||||
else {};
|
||||
in {
|
||||
options.plugins.${name} =
|
||||
{
|
||||
enable = mkEnableOption description;
|
||||
}
|
||||
// extraConfigOption
|
||||
// packageOption
|
||||
// pluginOptions;
|
||||
|
||||
|
|
|
@ -13,6 +13,6 @@ in
|
|||
package = pkgs.vimPlugins.vim-fugitive;
|
||||
extraPackages = [pkgs.git];
|
||||
|
||||
# In typical tpope fashin, this plugin has no config options
|
||||
# In typical tpope fashion, this plugin has no config options
|
||||
options = {};
|
||||
}
|
||||
|
|
|
@ -11,12 +11,13 @@ in
|
|||
name = "zig";
|
||||
description = "Enable zig";
|
||||
package = pkgs.vimPlugins.zig-vim;
|
||||
globalPrefix = "zig_";
|
||||
|
||||
# Possibly add option to disable Treesitter highlighting if this is installed
|
||||
options = {
|
||||
formatOnSave = mkDefaultOpt {
|
||||
type = types.bool;
|
||||
global = "zig_fmt_autosave";
|
||||
global = "fmt_autosave";
|
||||
description = "Run zig fmt on save";
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue