From d8f3b73b2c6c05fed83130340513ecaaaf5a5dd4 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sat, 3 Aug 2024 22:33:09 +0200 Subject: [PATCH] lib: add mkSetLuaBinding --- lib/binds.nix | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/binds.nix b/lib/binds.nix index ff22836..cafb5b4 100644 --- a/lib/binds.nix +++ b/lib/binds.nix @@ -3,6 +3,7 @@ inherit (lib.modules) mkIf mkDefault; inherit (lib.types) nullOr str; inherit (lib.attrsets) isAttrs mapAttrs; + inherit (lib.generators) mkLuaInline; mkLuaBinding = mode: key: action: desc: mkIf (key != null) { @@ -99,23 +100,17 @@ inherit mode lhs rhs desc; }; - # Usage: - # - # ``` - # vim.lazy.plugins = { - # telescope = { - # # ... - # keys = builtins.filter ({lhs, ...}: lhs != null) [ - # mkSetLznBinding mapping ":Telescope" - # ]; - # } - # } - # ``` mkSetLznBinding = binding: action: { lhs = binding.value; rhs = action; desc = binding.description; }; + + mkSetLuaLznBinding = binding: action: { + lhs = binding.value; + rhs = mkLuaInline "function() ${action} end"; + desc = binding.description; + }; }; in binds