mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-12-28 05:32:23 +00:00
lazy: use listOf plugins instead of attr
This commit is contained in:
parent
cb99286189
commit
ff38aeb820
3 changed files with 23 additions and 16 deletions
|
@ -21,8 +21,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.lazy = {
|
vim.lazy = {
|
||||||
plugins = {
|
plugins = [
|
||||||
nvim-tree-lua = {
|
{
|
||||||
package = "nvim-tree-lua";
|
package = "nvim-tree-lua";
|
||||||
setupModule = "nvim-tree";
|
setupModule = "nvim-tree";
|
||||||
inherit (cfg) setupOpts;
|
inherit (cfg) setupOpts;
|
||||||
|
@ -34,8 +34,8 @@ in {
|
||||||
(mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
(mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||||
(mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
(mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||||
];
|
];
|
||||||
};
|
}
|
||||||
};
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.pluginRC.nvimtreelua = entryAnywhere ''
|
vim.pluginRC.nvimtreelua = entryAnywhere ''
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) toJSON typeOf head length;
|
inherit (builtins) toJSON typeOf head length tryEval;
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.attrsets) mapAttrsToList;
|
inherit (lib.attrsets) mapAttrsToList;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
@ -31,7 +31,14 @@
|
||||||
inherit desc noremap expr nowait ft mode;
|
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"])
|
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
|
||||||
// {
|
// {
|
||||||
"@1" = name;
|
"@1" = name;
|
||||||
|
@ -64,12 +71,12 @@
|
||||||
then map toLuzLznKeySpec spec.keys
|
then map toLuzLznKeySpec spec.keys
|
||||||
else spec.keys;
|
else spec.keys;
|
||||||
};
|
};
|
||||||
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
|
lznSpecs = map toLuaLznSpec cfg.plugins;
|
||||||
in {
|
in {
|
||||||
config.vim = mkIf cfg.enable {
|
config.vim = mkIf cfg.enable {
|
||||||
startPlugins = ["lz-n" "lzn-auto-require"];
|
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"] ''
|
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] ''
|
||||||
require('lz.n').load(${toLuaObject lznSpecs})
|
require('lz.n').load(${toLuaObject lznSpecs})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib.types) enum;
|
inherit (lib.types) enum listOf;
|
||||||
inherit (lib.nvim.types) lznPluginTableType;
|
inherit (lib.nvim.types) lznPluginType;
|
||||||
in {
|
in {
|
||||||
options.vim.lazy = {
|
options.vim.lazy = {
|
||||||
enable = mkEnableOption "plugin lazy-loading" // {default = true;};
|
enable = mkEnableOption "plugin lazy-loading" // {default = true;};
|
||||||
|
@ -12,17 +12,17 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
plugins = mkOption {
|
plugins = mkOption {
|
||||||
default = {};
|
default = [];
|
||||||
type = lznPluginTableType;
|
type = listOf lznPluginType;
|
||||||
description = "list of plugins to lazy load";
|
description = "list of plugins to lazy load";
|
||||||
example = ''
|
example = ''
|
||||||
{
|
[
|
||||||
toggleterm-nvim = {
|
{
|
||||||
package = "toggleterm-nvim";
|
package = "toggleterm-nvim";
|
||||||
after = lib.generators.mkLuaInline "function() require('toggleterm').setup{} end";
|
after = lib.generators.mkLuaInline "function() require('toggleterm').setup{} end";
|
||||||
cmd = ["ToggleTerm"];
|
cmd = ["ToggleTerm"];
|
||||||
};
|
}
|
||||||
}
|
]
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue