mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
lib/plugins: make plugin optional when lazy-loading
This commit is contained in:
parent
87b2679d6f
commit
f878289722
5 changed files with 22 additions and 1 deletions
|
@ -46,6 +46,7 @@ lib.makeExtensible (
|
||||||
|
|
||||||
inherit (self.options)
|
inherit (self.options)
|
||||||
defaultNullOpts
|
defaultNullOpts
|
||||||
|
mkAutoLoadOption
|
||||||
mkCompositeOption
|
mkCompositeOption
|
||||||
mkCompositeOption'
|
mkCompositeOption'
|
||||||
mkLazyLoadOption
|
mkLazyLoadOption
|
||||||
|
|
|
@ -381,5 +381,18 @@ rec {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mkAutoLoadOption =
|
||||||
|
cfg: name:
|
||||||
|
lib.mkOption {
|
||||||
|
description = ''
|
||||||
|
Whether to automatically load ${name} when neovim starts.
|
||||||
|
'';
|
||||||
|
type = types.bool;
|
||||||
|
default = !(cfg.lazyLoad.enable or false);
|
||||||
|
defaultText =
|
||||||
|
if cfg ? lazyLoad then lib.literalMD "`false` when lazy-loading is enabled." else true;
|
||||||
|
example = false;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
// removed
|
// removed
|
||||||
|
|
|
@ -74,6 +74,7 @@ let
|
||||||
options = lib.setAttrByPath loc (
|
options = lib.setAttrByPath loc (
|
||||||
{
|
{
|
||||||
enable = lib.mkEnableOption packPathName;
|
enable = lib.mkEnableOption packPathName;
|
||||||
|
autoLoad = lib.nixvim.mkAutoLoadOption cfg packPathName;
|
||||||
lazyLoad = lib.nixvim.mkLazyLoadOption packPathName;
|
lazyLoad = lib.nixvim.mkLazyLoadOption packPathName;
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs hasSettings {
|
// lib.optionalAttrs hasSettings {
|
||||||
|
|
|
@ -67,6 +67,7 @@ let
|
||||||
options = lib.setAttrByPath loc (
|
options = lib.setAttrByPath loc (
|
||||||
{
|
{
|
||||||
enable = lib.mkEnableOption packPathName;
|
enable = lib.mkEnableOption packPathName;
|
||||||
|
autoLoad = lib.nixvim.mkAutoLoadOption cfg packPathName;
|
||||||
}
|
}
|
||||||
// settingsOption
|
// settingsOption
|
||||||
// extraOptions
|
// extraOptions
|
||||||
|
|
|
@ -74,7 +74,12 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
extraPlugins = [ (cfg.packageDecorator cfg.package) ];
|
extraPlugins = [
|
||||||
|
{
|
||||||
|
plugin = cfg.packageDecorator cfg.package;
|
||||||
|
optional = !cfg.autoLoad;
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue