Skip to content

Commit 9557341

Browse files
committed
modules/keymaps: add replace_keycodes keymap sub-option
1 parent fe95b14 commit 9557341

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/keymap-helpers.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{ lib }:
22
let
33
inherit (lib) optionalAttrs isAttrs types;
4-
inherit (lib.nixvim) defaultNullOpts mkNullOrStr;
4+
inherit (lib.nixvim) defaultNullOpts mkNullOrOption mkNullOrStr;
55
in
66
rec {
77
# These are the configuration options that change the behavior of each mapping.
@@ -23,6 +23,12 @@ rec {
2323
desc = mkNullOrStr "A textual description of this keybind, to be shown in which-key, if you have it.";
2424

2525
buffer = defaultNullOpts.mkBool false "Make the mapping buffer-local. Equivalent to adding `<buffer>` to a map.";
26+
27+
replace_keycodes = mkNullOrOption types.bool ''
28+
When `expr` is `true`, replace keycodes in the resulting string.
29+
30+
Returning `nil` from the Lua `callback` is equivalent to returning an empty string.
31+
'';
2632
};
2733

2834
modes = [

tests/test-sources/modules/keymaps.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
key = "<C-z>";
4949
action = "bar";
5050
}
51+
{
52+
mode = "n";
53+
key = "<C-h>";
54+
action.__raw = "function() end";
55+
options.replace_keycodes = false;
56+
}
5157
];
5258
};
5359

0 commit comments

Comments
 (0)