feat(nvim): change cmp binds again
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-08-07 10:41:41 -04:00
parent c3fa6e92ee
commit dafb2cf8ce
2 changed files with 8 additions and 21 deletions

View file

@ -78,10 +78,7 @@ in {
cmp-nvim-lsp
cmp-path
cmp-spell
cmp-treesitter
cmp-vsnip
vim-vsnip
friendly-snippets
])
++ [
{

View file

@ -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()
)
);
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
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<Right>'] = cmp.mapping.confirm({ select = true }),
-- Next selection
['<Down>'] = 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
['<Up>'] = cmp.mapping(function()
['<Up>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item();
else
fallback();
end;
end, {
'i',