Compare commits

...

4 commits

Author SHA1 Message Date
Ching Pei Yang
269d574720
Merge c7df5c97f3 into 773186d93d 2024-08-03 17:48:20 +00:00
Ching Pei Yang
c7df5c97f3 lz.n: generate less code 2024-08-03 19:48:13 +02:00
Ching Pei Yang
e086dc02fe lz.n: wrap lua code in function 2024-08-03 19:46:52 +02:00
Ching Pei Yang
fc58c85524 lib: add mkLznBinding 2024-08-03 19:18:25 +02:00
2 changed files with 42 additions and 9 deletions

View file

@ -71,6 +71,24 @@
mkLznBinding = mode: lhs: rhs: desc: { mkLznBinding = mode: lhs: rhs: desc: {
inherit mode lhs rhs desc; inherit mode lhs rhs desc;
}; };
# Usage:
#
# ```
# vim.lazy.plugins = {
# telescope = {
# # ...
# keys = builtins.filter ({lhs, ...}: lhs != null) [
# mkSetLznBinding mapping ":Telescope<CR>"
# ];
# }
# }
# ```
mkSetLznBinding = binding: action: {
lhs = binding.value;
rhs = action;
desc = binding.description;
};
}; };
in in
binds binds

View file

@ -31,7 +31,21 @@
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"]) (removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
// { // {
"@1" = name; "@1" = name;
after = mkLuaInline '' before =
if spec.before != null
then
mkLuaInline ''
function()
${spec.before}
end
''
else null;
after =
if spec.setupModule == null && spec.after == null
then null
else
mkLuaInline ''
function() function()
${ ${
optionalString (spec.setupModule != null) optionalString (spec.setupModule != null)
@ -40,6 +54,7 @@
${optionalString (spec.after != null) spec.after} ${optionalString (spec.after != null) spec.after}
end end
''; '';
keys = keys =
if typeOf spec.keys == "list" && length spec.keys > 0 && typeOf (head spec.keys) == "set" if typeOf spec.keys == "list" && length spec.keys > 0 && typeOf (head spec.keys) == "set"
then map toLuzLznKeySpec spec.keys then map toLuzLznKeySpec spec.keys