From c4e491a87eeacf0408902c32f031d802c7eafce8 Mon Sep 17 00:00:00 2001 From: sandersantema Date: Mon, 10 Jul 2023 06:57:29 +0200 Subject: [PATCH] perf: fix `nvim_replace_termcodes` being called on every `CursorMoved` (#1650) --- plugin/cmp.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/cmp.lua b/plugin/cmp.lua index eaacad83f..0e5e69180 100644 --- a/plugin/cmp.lua +++ b/plugin/cmp.lua @@ -41,8 +41,9 @@ end) autocmd.emit('ColorScheme') if vim.on_key then + local control_c_termcode = vim.api.nvim_replace_termcodes('', true, true, true) vim.on_key(function(keys) - if keys == vim.api.nvim_replace_termcodes('', true, true, true) then + if keys == control_c_termcode then vim.schedule(function() if not api.is_suitable_mode() then autocmd.emit('InsertLeave') @@ -52,6 +53,7 @@ if vim.on_key then end, vim.api.nvim_create_namespace('cmp.plugin')) end + vim.api.nvim_create_user_command('CmpStatus', function() require('cmp').status() end, { desc = 'Check status of cmp sources' })