Skip to content

Commit

Permalink
fix: allow "bidirectional" mappings (e.g., kj and jk) (#67)
Browse files Browse the repository at this point in the history
Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com>
  • Loading branch information
Jint-lzxy authored Jul 7, 2024
1 parent 78cdf5d commit bbfdf77
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lua/better_escape.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ local function map_keys()
for mode, keys in pairs(settings.mappings) do
local map_opts = { expr = true }
for key, subkeys in pairs(keys) do
vim.keymap.set(mode, key, function()
log_key(key)
return key
end, map_opts)
-- Ensure correct registration of bidirectional mappings (e.g., `kj` and `jk`). #67
if vim.fn.maparg(key, mode) == "" then
vim.keymap.set(mode, key, function()
log_key(key)
return key
end, map_opts)
end
for subkey, mapping in pairs(subkeys) do
if mapping then
if not parent_keys[mode] then
Expand Down

0 comments on commit bbfdf77

Please sign in to comment.