Repository navigation
fix: normalize keymap keys before merging user config - #724
Closed
barrettruth wants to merge 1 commit into
Closed
barrettruth wants to merge 1 commit into
barrettruth wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Keymap overrides using non-canonical casing (e.g.
<c-t>instead of<C-t>) fail to replace the corresponding default keymap. The keys are compared as raw strings during the merge inconfig.setup(), so both the user entry and the default entry remain in the table. Depending onpairs()iteration order, the default may overwrite the user's override when applied viavim.keymap.set.Solution
Normalize keymap keys with
vim.api.nvim_replace_termcodesduring the merge loop. Before inserting each user keymap, any existing default key that normalizes to the same internal representation is removed, ensuring the user's entry is the only one that survives.Closes #692