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: {
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
binds

View file

@ -31,15 +31,30 @@
(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
'';
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()
${
optionalString (spec.setupModule != null)
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"
}
${optionalString (spec.after != null) spec.after}
end
'';
keys =
if typeOf spec.keys == "list" && length spec.keys > 0 && typeOf (head spec.keys) == "set"
then map toLuzLznKeySpec spec.keys