From 723145c9fb9c95f280b2468b5f40f80af0a86074 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 20 Feb 2026 16:26:03 -0500 Subject: [PATCH] fix: normalize keymap keys before merging user config Problem: user keymap overrides like failed to replace the default 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 --- lua/oil/config.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/oil/config.lua b/lua/oil/config.lua index cafa783..c59e1bb 100644 --- a/lua/oil/config.lua +++ b/lua/oil/config.lua @@ -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