refactor(nvim): condense functions
This commit is contained in:
parent
0c591c0435
commit
1566dc84f4
1 changed files with 7 additions and 17 deletions
|
@ -24,38 +24,28 @@ let
|
||||||
then func
|
then func
|
||||||
else abort "Either cmd or function must be set"
|
else abort "Either cmd or function must be set"
|
||||||
);
|
);
|
||||||
|
descString = optionalString (desc != null) "desc = ${quote desc},";
|
||||||
in
|
in
|
||||||
''{ ${quote key}, ${cmdString}, mode = ${quote mode}, ${optionalString (desc != null) "desc = ${quote desc},"} }'';
|
''{ ${quote key}, ${cmdString}, mode = ${quote mode}, ${descString} }'';
|
||||||
lazySpecFromPlugin =
|
lazySpecFromPlugin =
|
||||||
{ plugin
|
{ plugin, dependencies, init, conf, lazy, event, enabled, cmd, ft, priority, keys }:
|
||||||
, dependencies
|
listToStringMultiLine'
|
||||||
, init
|
|
||||||
, conf
|
|
||||||
, lazy
|
|
||||||
, event
|
|
||||||
, enabled
|
|
||||||
, cmd
|
|
||||||
, ft
|
|
||||||
, priority
|
|
||||||
, keys
|
|
||||||
}:
|
|
||||||
listToStringMultiLine id
|
|
||||||
([
|
([
|
||||||
"dir = ${quote plugin}"
|
"dir = ${quote plugin}"
|
||||||
"name = ${quote (getName plugin)}"
|
"name = ${quote (getName plugin)}"
|
||||||
]
|
]
|
||||||
++ (optional (lazy != null) "lazy = ${boolToString lazy}")
|
++ (optional (lazy != null) "lazy = ${boolToString lazy}")
|
||||||
++ (optional (!enabled) "enabled = ${boolToString enabled}")
|
++ (optional (!enabled) "enabled = ${boolToString enabled}")
|
||||||
++ (optional (dependencies != [ ]) "dependencies = ${listToStringMultiLine id (map lazySpecFromPlugin dependencies)}")
|
++ (optional (dependencies != [ ]) "dependencies = ${listToStringMultiLine' (map lazySpecFromPlugin dependencies)}")
|
||||||
++ (optional (init != null) "init = function(plugin)\n${toString init}\nend")
|
++ (optional (init != null) "init = function(plugin)\n${toString init}\nend")
|
||||||
++ (optional (conf != null) "config = function(plugin, opts)\n${toString conf}\nend")
|
++ (optional (conf != null) "config = function(plugin, opts)\n${toString conf}\nend")
|
||||||
++ (optional (keys != [ ]) "keys = ${listToStringMultiLine id (map keybinding keys)}")
|
++ (optional (keys != [ ]) "keys = ${listToStringMultiLine' (map keybinding keys)}")
|
||||||
++ (optional (event != [ ]) "event = ${listToStringOneLine quote event}")
|
++ (optional (event != [ ]) "event = ${listToStringOneLine quote event}")
|
||||||
++ (optional (cmd != [ ]) "cmd = ${listToStringOneLine quote cmd}")
|
++ (optional (cmd != [ ]) "cmd = ${listToStringOneLine quote cmd}")
|
||||||
++ (optional (ft != [ ]) "ft = ${listToStringOneLine quote ft}")
|
++ (optional (ft != [ ]) "ft = ${listToStringOneLine quote ft}")
|
||||||
++ (optional (priority != null) "priority = ${toString priority}")
|
++ (optional (priority != null) "priority = ${toString priority}")
|
||||||
);
|
);
|
||||||
lazySpecs = listToStringMultiLine id (map lazySpecFromPlugin cfg.plugins);
|
lazySpecs = listToStringMultiLine' (map lazySpecFromPlugin cfg.plugins);
|
||||||
lazy = /* lua */ ''
|
lazy = /* lua */ ''
|
||||||
require("lazy").setup(${lazySpecs})
|
require("lazy").setup(${lazySpecs})
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in a new issue