From 40e5e5079e8ad1c25c43f2c3a4b4257c632177da Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 5 Oct 2024 19:21:00 +0200 Subject: [PATCH 1/3] map: fix misinformation --- modules/neovim/mappings/options.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/neovim/mappings/options.nix b/modules/neovim/mappings/options.nix index 49e72494..1dd4897c 100644 --- a/modules/neovim/mappings/options.nix +++ b/modules/neovim/mappings/options.nix @@ -44,7 +44,7 @@ See `:help map-modes` for a list of modes. ''; - example = ''"nvc" for normal, visual and command mode''; + example = ''`["n" "v" "c"]` for normal, visual and command mode''; }; }; }; From f4ff635a657c20353afc8bd9cbd19377566ca59a Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 5 Oct 2024 19:26:10 +0200 Subject: [PATCH 2/3] map: remove redundant variable --- modules/neovim/mappings/options.nix | 39 +++++++++++++---------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/modules/neovim/mappings/options.nix b/modules/neovim/mappings/options.nix index 1dd4897c..f05de21b 100644 --- a/modules/neovim/mappings/options.nix +++ b/modules/neovim/mappings/options.nix @@ -1,6 +1,6 @@ {lib, ...}: let inherit (lib.options) mkOption; - inherit (lib.types) either str listOf attrsOf nullOr submodule bool; + inherit (lib.types) either str listOf attrsOf nullOr submodule; inherit (lib.nvim.config) mkBool; mapConfigOptions = { @@ -33,9 +33,7 @@ // { key = mkOption { type = str; - description = '' - Key that triggers this keybind. - ''; + description = "The key that triggers this keybind."; }; mode = mkOption { type = either str (listOf str); @@ -49,15 +47,12 @@ }; }; - # legacy stuff - legacyMapOption = submodule { - options = mapConfigOptions; - }; - - mapOptions = mode: + legacyMapOption = mode: mkOption { description = "Mappings for ${mode} mode"; - type = attrsOf legacyMapOption; + type = attrsOf (submodule { + options = mapConfigOptions; + }); default = {}; }; in { @@ -85,18 +80,18 @@ in { }; maps = { - normal = mapOptions "normal"; - insert = mapOptions "insert"; - select = mapOptions "select"; - visual = mapOptions "visual and select"; - terminal = mapOptions "terminal"; - normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')"; + normal = legacyMapOption "normal"; + insert = legacyMapOption "insert"; + select = legacyMapOption "select"; + visual = legacyMapOption "visual and select"; + terminal = legacyMapOption "terminal"; + normalVisualOp = legacyMapOption "normal, visual, select and operator-pending (same as plain 'map')"; - visualOnly = mapOptions "visual only"; - operator = mapOptions "operator-pending"; - insertCommand = mapOptions "insert and command-line"; - lang = mapOptions "insert, command-line and lang-arg"; - command = mapOptions "command-line"; + visualOnly = legacyMapOption "visual only"; + operator = legacyMapOption "operator-pending"; + insertCommand = legacyMapOption "insert and command-line"; + lang = legacyMapOption "insert, command-line and lang-arg"; + command = legacyMapOption "command-line"; }; }; } From 8154c3e68f076f78cfa3b60acb1823c29b2e4953 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 5 Oct 2024 19:31:59 +0200 Subject: [PATCH 3/3] fixup! mappings: impl keymap option --- modules/wrapper/rc/config.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index 2a950a25..6f9ed1ce 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -43,9 +43,7 @@ in { toLuaKeymap = bind: "vim.keymap.set(${toLuaObject bind.mode}, ${toLuaObject bind.key}, ${toLuaObject (getAction bind)}, ${toLuaObject (getOpts bind)})"; - maps = concatLines (map toLuaKeymap cfg.keymaps); - - keymaps = maps; + keymaps = concatLines (map toLuaKeymap cfg.keymaps); in { vim = { luaConfigRC = {