From e1dd7909e00cdb63d599e0aadb0819300b313661 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Fri, 2 Aug 2024 00:08:30 -0400 Subject: [PATCH] feat(nvim): change cmp binds --- common/home/neovim/plugins/cmp.lua | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/common/home/neovim/plugins/cmp.lua b/common/home/neovim/plugins/cmp.lua index 1f903100..2c1217c1 100644 --- a/common/home/neovim/plugins/cmp.lua +++ b/common/home/neovim/plugins/cmp.lua @@ -3,14 +3,11 @@ local has_words_before = function() return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil; end; -local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true); -end; - local cmp = require('cmp'); -- If you want insert `(` after select function or method item local cmp_autopairs = require('nvim-autopairs.completion.cmp') + cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done() @@ -33,12 +30,13 @@ cmp.setup({ }, mapping = { + -- Confirm selection [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping(function(fallback) + + -- Next selection + [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item(); - elseif vim.fn['vsnip#available'](1) == 1 then - feedkey('(vsnip-expand-or-jump)', ''); elseif has_words_before() then cmp.complete(); else @@ -49,11 +47,10 @@ cmp.setup({ 's', }), - [''] = cmp.mapping(function() + -- Previous selection + [''] = cmp.mapping(function() if cmp.visible() then cmp.select_prev_item(); - elseif vim.fn['vsnip#jumpable'](-1) == 1 then - feedkey('(vsnip-jump-prev)', ''); end; end, { 'i',