From dafb2cf8ceaac33d9062ad50918522991399d855 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Wed, 7 Aug 2024 10:41:41 -0400 Subject: [PATCH] feat(nvim): change cmp binds again --- common/home/neovim/langs/default.nix | 3 --- common/home/neovim/plugins/cmp.lua | 26 ++++++++------------------ 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/common/home/neovim/langs/default.nix b/common/home/neovim/langs/default.nix index 4b7ee13d..0f168e20 100644 --- a/common/home/neovim/langs/default.nix +++ b/common/home/neovim/langs/default.nix @@ -78,10 +78,7 @@ in { cmp-nvim-lsp cmp-path cmp-spell - cmp-treesitter - cmp-vsnip vim-vsnip - friendly-snippets ]) ++ [ { diff --git a/common/home/neovim/plugins/cmp.lua b/common/home/neovim/plugins/cmp.lua index 2c1217c1..54a38adf 100644 --- a/common/home/neovim/plugins/cmp.lua +++ b/common/home/neovim/plugins/cmp.lua @@ -1,26 +1,16 @@ -local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)); - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil; -end; - local cmp = require('cmp'); - --- If you want insert `(` after select function or method item -local cmp_autopairs = require('nvim-autopairs.completion.cmp') +local cmp_autopairs = require('nvim-autopairs.completion.cmp'); cmp.event:on( - 'confirm_done', - cmp_autopairs.on_confirm_done() -) + 'confirm_done', + cmp_autopairs.on_confirm_done() +); cmp.setup({ sources = { { name = 'nvim_lsp' }, - { name = 'cmp_tabnine' }, - { name = 'treesitter' }, { name = 'buffer' }, { name = 'path' }, - { name = 'vsnip' }, }, snippet = { @@ -31,14 +21,12 @@ cmp.setup({ mapping = { -- Confirm selection - [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.confirm({ select = true }), -- Next selection [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item(); - elseif has_words_before() then - cmp.complete(); else fallback(); end; @@ -48,9 +36,11 @@ cmp.setup({ }), -- Previous selection - [''] = cmp.mapping(function() + [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item(); + else + fallback(); end; end, { 'i',