perf: fix nvim_replace_termcodes being called on every CursorMoved (#1650)

This commit is contained in:
sandersantema
2023-07-10 06:57:29 +02:00
committed by GitHub
parent 2743dd989e
commit c4e491a87e

View File

@@ -41,8 +41,9 @@ end)
autocmd.emit('ColorScheme') autocmd.emit('ColorScheme')
if vim.on_key then if vim.on_key then
local control_c_termcode = vim.api.nvim_replace_termcodes('<C-c>', true, true, true)
vim.on_key(function(keys) vim.on_key(function(keys)
if keys == vim.api.nvim_replace_termcodes('<C-c>', true, true, true) then if keys == control_c_termcode then
vim.schedule(function() vim.schedule(function()
if not api.is_suitable_mode() then if not api.is_suitable_mode() then
autocmd.emit('InsertLeave') 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_namespace('cmp.plugin'))
end end
vim.api.nvim_create_user_command('CmpStatus', function() vim.api.nvim_create_user_command('CmpStatus', function()
require('cmp').status() require('cmp').status()
end, { desc = 'Check status of cmp sources' }) end, { desc = 'Check status of cmp sources' })