From 945b9e650058272ac961572640d3ef6152fece0c Mon Sep 17 00:00:00 2001 From: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:30:20 +0200 Subject: [PATCH] lazy: use similar API to nvf keymaps --- lib/types/plugins.nix | 15 ++++++++++----- modules/wrapper/lazy/config.nix | 12 ++++++++---- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index d83c48fe..85327726 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -88,16 +88,21 @@ default = null; }; - lhs = mkOption { + key = mkOption { type = str; description = "Key to bind to"; }; - rhs = mkOption { - type = nullOr (either str luaInline); + action = mkOption { + type = nullOr str; default = null; - # FIXME: use a separate flag to indicate lua instead of luaInline - description = "Action to trigger. luaInline code will be wrapped in a function."; + description = "Action to trigger."; + }; + + lua = mkOption { + type = bool; + default = false; + description = "If true the action is treated as a lua function instead of a vim command."; }; mode = mkOption { diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index 7baefa45..1ad90eee 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -18,12 +18,16 @@ expr, nowait, ft, - lhs, - rhs, + key, + action, + lua, mode, }: { - "@1" = lhs; - "@2" = rhs; + "@1" = key; + "@2" = + if lua + then mkLuaInline action + else action; inherit desc noremap expr nowait ft mode; };