lib: add mkSetLuaBinding

This commit is contained in:
Ching Pei Yang 2024-08-03 22:33:09 +02:00 committed by Pei Yang Ching
parent fcc360c3ce
commit d8f3b73b2c

View file

@ -3,6 +3,7 @@
inherit (lib.modules) mkIf mkDefault; inherit (lib.modules) mkIf mkDefault;
inherit (lib.types) nullOr str; inherit (lib.types) nullOr str;
inherit (lib.attrsets) isAttrs mapAttrs; inherit (lib.attrsets) isAttrs mapAttrs;
inherit (lib.generators) mkLuaInline;
mkLuaBinding = mode: key: action: desc: mkLuaBinding = mode: key: action: desc:
mkIf (key != null) { mkIf (key != null) {
@ -99,23 +100,17 @@
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: { mkSetLznBinding = binding: action: {
lhs = binding.value; lhs = binding.value;
rhs = action; rhs = action;
desc = binding.description; desc = binding.description;
}; };
mkSetLuaLznBinding = binding: action: {
lhs = binding.value;
rhs = mkLuaInline "function() ${action} end";
desc = binding.description;
};
}; };
in in
binds binds