Skip to content

Commit

Permalink
fix: use \<* notation for keymap.normalize (hrsh7th#2069)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeertzjq authored and xzbdmw committed Oct 22, 2024
1 parent 266e3fe commit f3b402b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lua/cmp/utils/keymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ end
---@param keys string
---@return string
keymap.normalize = vim.fn.has('nvim-0.8') == 1 and function(keys)
return vim.fn.keytrans(keymap.t(keys))
local t = string.gsub(keys, '<([A-Za-z0-9\\%-%[%]%^@]-)>', function(match)
-- Use the \<* notation, which distinguishes <C-J> from <NL>, etc.
return vim.api.nvim_eval(string.format([["\<*%s>"]], match))
end)
return vim.fn.keytrans(t)
end or function(keys)
local normalize_buf = buffer.ensure('cmp.util.keymap.normalize')
vim.api.nvim_buf_set_keymap(normalize_buf, 't', keys, '<Plug>(cmp.utils.keymap.normalize)', {})
Expand Down

0 comments on commit f3b402b

Please sign in to comment.