refactor(nvim): overhaul nix glue and be more lazy
This commit is contained in:
parent
21bba2e8fd
commit
9a920427a9
5 changed files with 63 additions and 94 deletions
|
|
@ -9,7 +9,10 @@ let
|
|||
cfg = config.my.programs.nvim;
|
||||
boolToString = bool: if bool then "true" else "false";
|
||||
quote = str: ''"${toString str}"'';
|
||||
listToString = list: ''{ ${concatStringsSep ", " (map quote list)} }'';
|
||||
id = x: x;
|
||||
listToString = sep: f: list: ''{ ${concatStringsSep sep (map f list)} }'';
|
||||
listToStringOneLine = listToString ", ";
|
||||
listToStringMultiLine = listToString ",\n";
|
||||
keybinding =
|
||||
{ key
|
||||
, cmd
|
||||
|
|
@ -42,31 +45,23 @@ let
|
|||
, priority
|
||||
, keys
|
||||
}:
|
||||
''
|
||||
{
|
||||
dir = "${plugin}",
|
||||
name = "${plugin.name}",
|
||||
lazy = ${boolToString lazy},
|
||||
enabled = ${boolToString enabled},
|
||||
dependencies = { ${concatStringsSep ", " (map lazySpecFromPlugin dependencies)} },
|
||||
${optionalString (init != null)
|
||||
"init = function(plugin)
|
||||
${toString init}
|
||||
end,"
|
||||
}
|
||||
${optionalString (conf != null)
|
||||
"config = function(plugin, opts)
|
||||
${toString conf}
|
||||
end,"
|
||||
}
|
||||
keys = { ${concatStringsSep ",\n" (map keybinding keys)} },
|
||||
event = ${listToString event},
|
||||
cmd = ${listToString cmd},
|
||||
ft = ${listToString ft},
|
||||
priority = ${toString priority},
|
||||
}
|
||||
'';
|
||||
lazySpecs = concatStringsSep ", " (map lazySpecFromPlugin cfg.plugins);
|
||||
listToStringMultiLine id
|
||||
([
|
||||
"dir = ${quote plugin}"
|
||||
"name = ${quote plugin.name}"
|
||||
"lazy = ${boolToString lazy}"
|
||||
]
|
||||
++ (optional (!enabled) "enabled = ${boolToString enabled}")
|
||||
++ (optional (dependencies != [ ]) "dependencies = ${listToStringMultiLine id (map lazySpecFromPlugin dependencies)}")
|
||||
++ (optional (init != null) "init = function(plugin)\n${toString init}\nend")
|
||||
++ (optional (conf != null) "config = function(plugin, opts)\n${toString conf}\nend")
|
||||
++ (optional (keys != [ ]) "keys = ${listToStringMultiLine id (map keybinding keys)}")
|
||||
++ (optional (event != [ ]) "event = ${listToStringOneLine quote event}")
|
||||
++ (optional (cmd != [ ]) "cmd = ${listToStringOneLine quote cmd}")
|
||||
++ (optional (ft != [ ]) "ft = ${listToStringOneLine quote ft}")
|
||||
++ (optional (priority != 50) "priority = ${toString priority}")
|
||||
);
|
||||
lazySpecs = listToStringMultiLine id (map lazySpecFromPlugin cfg.plugins);
|
||||
lazy = ''
|
||||
require("lazy").setup({
|
||||
${lazySpecs}
|
||||
|
|
@ -117,7 +112,7 @@ in
|
|||
};
|
||||
lazy = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to load the plugin lazily.
|
||||
'';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue