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:
parent
dcb3a08776
commit
723145c9fb
1 changed files with 6 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue