Skip to content

Commit bbfdf77

Browse files
authored
fix: allow "bidirectional" mappings (e.g., kj and jk) (#67)
Signed-off-by: Jint-lzxy <[email protected]>
1 parent 78cdf5d commit bbfdf77

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lua/better_escape.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,13 @@ local function map_keys()
8989
for mode, keys in pairs(settings.mappings) do
9090
local map_opts = { expr = true }
9191
for key, subkeys in pairs(keys) do
92-
vim.keymap.set(mode, key, function()
93-
log_key(key)
94-
return key
95-
end, map_opts)
92+
-- Ensure correct registration of bidirectional mappings (e.g., `kj` and `jk`). #67
93+
if vim.fn.maparg(key, mode) == "" then
94+
vim.keymap.set(mode, key, function()
95+
log_key(key)
96+
return key
97+
end, map_opts)
98+
end
9699
for subkey, mapping in pairs(subkeys) do
97100
if mapping then
98101
if not parent_keys[mode] then

0 commit comments

Comments
 (0)