fix: normalize keymap keys before merging user config

Problem: user keymap overrides like <c-t> failed to replace the
default <C-t> because the keys were compared as raw strings during
merge, leaving both entries in the table.

Solution: use nvim_replace_termcodes to compare keymap keys by their
internal representation, removing any default entry that normalizes
to the same key as the user-provided one before inserting it.

Closes #692
Cherry-picked from: stevearc/oil.nvim#725
This commit is contained in:
Barrett Ruth 2026-02-20 16:26:03 -05:00
parent dcb3a08776
commit 723145c9fb

View file

@ -409,6 +409,12 @@ M.setup = function(opts)
-- We don't want to deep merge the keymaps, we want any keymap defined by the user to override
-- everything about the default.
for k, v in pairs(opts.keymaps) do
local normalized = vim.api.nvim_replace_termcodes(k, true, true, true)
for existing_k, _ in pairs(new_conf.keymaps) do
if existing_k ~= k and vim.api.nvim_replace_termcodes(existing_k, true, true, true) == normalized then
new_conf.keymaps[existing_k] = nil
end
end
new_conf.keymaps[k] = v
end
end