mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-23 13:50:44 +00:00
57 lines
1.3 KiB
Nix
57 lines
1.3 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
...
|
|
}: let
|
|
inherit (builtins) toJSON;
|
|
inherit (lib.modules) mkIf;
|
|
inherit (lib.attrsets) mapAttrsToList;
|
|
inherit (lib.generators) mkLuaInline;
|
|
inherit (lib.strings) optionalString;
|
|
inherit (lib.nvim.lua) toLuaObject;
|
|
inherit (lib.nvim.dag) entryAnywhere;
|
|
cfg = config.vim.lazy;
|
|
|
|
toLuzLznKeySpec = {
|
|
desc,
|
|
noremap,
|
|
expr,
|
|
nowait,
|
|
ft,
|
|
lhs,
|
|
rhs,
|
|
mode,
|
|
}: {
|
|
"@1" = lhs;
|
|
"@2" = rhs;
|
|
inherit desc noremap expr nowait ft mode;
|
|
};
|
|
|
|
toLuaLznSpec = name: spec:
|
|
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
|
|
// {
|
|
"@1" = name;
|
|
after = mkLuaInline ''
|
|
function()
|
|
${
|
|
optionalString (spec.setupModule != null)
|
|
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"
|
|
}
|
|
${optionalString (spec.after != null) spec.after}
|
|
end
|
|
'';
|
|
keys = map toLuzLznKeySpec spec.keys;
|
|
};
|
|
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
|
|
in {
|
|
config.vim = mkIf cfg.enable {
|
|
startPlugins = ["lz-n"];
|
|
|
|
optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
|
|
|
|
luaConfigRC.lzn-load = entryAnywhere ''
|
|
require('lz.n').load(${toLuaObject lznSpecs})
|
|
'';
|
|
};
|
|
}
|