Skip to content

Commit

Permalink
perf: use builtin for key normalization (#1935)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtomjhj authored Oct 21, 2024
1 parent 82bd4b5 commit 2c93d5e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/cmp/utils/keymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ end
---Normalize key sequence.
---@param keys string
---@return string
keymap.normalize = function(keys)
keymap.normalize = vim.fn.has('nvim-0.8') == 1 and function(keys)
return vim.fn.keytrans(keymap.t(keys))
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)', {})
for _, map in ipairs(vim.api.nvim_buf_get_keymap(normalize_buf, 't')) do
Expand Down

0 comments on commit 2c93d5e

Please sign in to comment.