mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-12-19 18:31:18 +00:00
lazy: use listOf plugins instead of attr
This commit is contained in:
parent
2a7a268c1f
commit
52f1675ca6
3 changed files with 23 additions and 16 deletions
|
|
@ -3,7 +3,7 @@
|
|||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON typeOf head length;
|
||||
inherit (builtins) toJSON typeOf head length tryEval;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
|
|
@ -31,7 +31,14 @@
|
|||
inherit desc noremap expr nowait ft mode;
|
||||
};
|
||||
|
||||
toLuaLznSpec = name: spec:
|
||||
toLuaLznSpec = spec: let
|
||||
name =
|
||||
if typeOf spec.package == "string"
|
||||
then spec.package
|
||||
else if (spec.package ? pname && (tryEval spec.package.pname).success)
|
||||
then spec.package.pname
|
||||
else spec.package.name;
|
||||
in
|
||||
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
|
||||
// {
|
||||
"@1" = name;
|
||||
|
|
@ -64,12 +71,12 @@
|
|||
then map toLuzLznKeySpec spec.keys
|
||||
else spec.keys;
|
||||
};
|
||||
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
|
||||
lznSpecs = map toLuaLznSpec cfg.plugins;
|
||||
in {
|
||||
config.vim = mkIf cfg.enable {
|
||||
startPlugins = ["lz-n" "lzn-auto-require"];
|
||||
|
||||
optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
|
||||
optPlugins = map (plugin: plugin.package) cfg.plugins;
|
||||
|
||||
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] ''
|
||||
require('lz.n').load(${toLuaObject lznSpecs})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue