mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-27 19:18:57 +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
|
}: let
|
||||||
cfg = config.plugins.${name};
|
cfg = config.plugins.${name};
|
||||||
|
|
||||||
|
description =
|
||||||
|
if description is null
|
||||||
|
then name
|
||||||
|
else description;
|
||||||
|
|
||||||
# TODO support nested options!
|
# TODO support nested options!
|
||||||
pluginOptions = mapAttrs (k: v: v.option) options;
|
pluginOptions =
|
||||||
|
mapAttrs
|
||||||
|
(
|
||||||
|
optName: opt:
|
||||||
|
opt.option
|
||||||
|
)
|
||||||
|
options;
|
||||||
globals =
|
globals =
|
||||||
mapAttrs'
|
mapAttrs'
|
||||||
(name: opt: {
|
(optName: opt: {
|
||||||
name = globalPrefix + opt.global;
|
name = globalPrefix + opt.global;
|
||||||
value =
|
value =
|
||||||
if cfg.${name} != null
|
ifNonNull' cfg.${optName}
|
||||||
then opt.value cfg.${name}
|
(opt.value cfg.${optName});
|
||||||
else null;
|
|
||||||
})
|
})
|
||||||
options;
|
options;
|
||||||
# does this evaluate package?
|
# does this evaluate package?
|
||||||
|
@ -341,11 +352,31 @@ with lib; rec {
|
||||||
else {
|
else {
|
||||||
package = mkPackageOption name package;
|
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 {
|
in {
|
||||||
options.plugins.${name} =
|
options.plugins.${name} =
|
||||||
{
|
{
|
||||||
enable = mkEnableOption description;
|
enable = mkEnableOption description;
|
||||||
}
|
}
|
||||||
|
// extraConfigOption
|
||||||
// packageOption
|
// packageOption
|
||||||
// pluginOptions;
|
// pluginOptions;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,6 @@ in
|
||||||
package = pkgs.vimPlugins.vim-fugitive;
|
package = pkgs.vimPlugins.vim-fugitive;
|
||||||
extraPackages = [pkgs.git];
|
extraPackages = [pkgs.git];
|
||||||
|
|
||||||
# In typical tpope fashin, this plugin has no config options
|
# In typical tpope fashion, this plugin has no config options
|
||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,13 @@ in
|
||||||
name = "zig";
|
name = "zig";
|
||||||
description = "Enable zig";
|
description = "Enable zig";
|
||||||
package = pkgs.vimPlugins.zig-vim;
|
package = pkgs.vimPlugins.zig-vim;
|
||||||
|
globalPrefix = "zig_";
|
||||||
|
|
||||||
# Possibly add option to disable Treesitter highlighting if this is installed
|
# Possibly add option to disable Treesitter highlighting if this is installed
|
||||||
options = {
|
options = {
|
||||||
formatOnSave = mkDefaultOpt {
|
formatOnSave = mkDefaultOpt {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
global = "zig_fmt_autosave";
|
global = "fmt_autosave";
|
||||||
description = "Run zig fmt on save";
|
description = "Run zig fmt on save";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue