From 8b2cba005a2583691a87f61d8322eb6131dc91a0 Mon Sep 17 00:00:00 2001 From: Christoffer N Date: Wed, 27 Nov 2024 14:12:05 +0100 Subject: [PATCH] fix: make work again --- lua/cmp/utils/keymap.lua | 34 +++++++++++++++++----------------- lua/cmp/utils/keymap_spec.lua | 1 + 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lua/cmp/utils/keymap.lua b/lua/cmp/utils/keymap.lua index fa9b4ca1e..09e1807d8 100644 --- a/lua/cmp/utils/keymap.lua +++ b/lua/cmp/utils/keymap.lua @@ -8,7 +8,7 @@ local keymap = {} ---@param keys string ---@return string keymap.t = function(keys) - return (string.gsub(keys, "(<[A-Za-z0-9\\%-%[%]%^@;,:_']->)", function(match) + return (string.gsub(keys, "(<[A-Za-z0-9\\%-%[%]%^@;,:_'.]->)", function(match) return vim.api.nvim_eval(string.format([["\%s"]], match)) end)) end @@ -17,24 +17,24 @@ end ---@param keys string ---@return string keymap.normalize = vim.fn.has('nvim-0.8') == 1 and function(keys) - local t = string.gsub(keys, "<([A-Za-z0-9\\%-%[%]%^@;,:_']-)>", function(match) - -- Use the \<* notation, which distinguishes from , 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, '(cmp.utils.keymap.normalize)', {}) - for _, map in ipairs(vim.api.nvim_buf_get_keymap(normalize_buf, 't')) do - if keymap.t(map.rhs) == keymap.t('(cmp.utils.keymap.normalize)') then - vim.api.nvim_buf_del_keymap(normalize_buf, 't', keys) - return map.lhs - end + local t = string.gsub(keys, "<([A-Za-z0-9\\%-%[%]%^@;,:_']-)>", function(match) + -- Use the \<* notation, which distinguishes from , 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, '(cmp.utils.keymap.normalize)', {}) + for _, map in ipairs(vim.api.nvim_buf_get_keymap(normalize_buf, 't')) do + if keymap.t(map.rhs) == keymap.t('(cmp.utils.keymap.normalize)') then + vim.api.nvim_buf_del_keymap(normalize_buf, 't', keys) + return map.lhs end - vim.api.nvim_buf_del_keymap(normalize_buf, 't', keys) - vim.api.nvim_buf_delete(normalize_buf, {}) - return keys end + vim.api.nvim_buf_del_keymap(normalize_buf, 't', keys) + vim.api.nvim_buf_delete(normalize_buf, {}) + return keys +end ---Return vim notation keymapping (simple conversion). ---@param s string diff --git a/lua/cmp/utils/keymap_spec.lua b/lua/cmp/utils/keymap_spec.lua index 3d9c35d9e..9ee4ca0ea 100644 --- a/lua/cmp/utils/keymap_spec.lua +++ b/lua/cmp/utils/keymap_spec.lua @@ -18,6 +18,7 @@ describe('keymap', function() '', '', '', + '', '', '', "",