feat(nvim): change cmp binds
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
59675a6d1f
commit
e1dd7909e0
1 changed files with 7 additions and 10 deletions
|
@ -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;
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil;
|
||||||
end;
|
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');
|
local cmp = require('cmp');
|
||||||
|
|
||||||
-- If you want insert `(` after select function or method item
|
-- 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(
|
cmp.event:on(
|
||||||
'confirm_done',
|
'confirm_done',
|
||||||
cmp_autopairs.on_confirm_done()
|
cmp_autopairs.on_confirm_done()
|
||||||
|
@ -33,12 +30,13 @@ cmp.setup({
|
||||||
},
|
},
|
||||||
|
|
||||||
mapping = {
|
mapping = {
|
||||||
|
-- Confirm selection
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||||
['<Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
|
-- Next selection
|
||||||
|
['<Down>'] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item();
|
cmp.select_next_item();
|
||||||
elseif vim.fn['vsnip#available'](1) == 1 then
|
|
||||||
feedkey('<Plug>(vsnip-expand-or-jump)', '');
|
|
||||||
elseif has_words_before() then
|
elseif has_words_before() then
|
||||||
cmp.complete();
|
cmp.complete();
|
||||||
else
|
else
|
||||||
|
@ -49,11 +47,10 @@ cmp.setup({
|
||||||
's',
|
's',
|
||||||
}),
|
}),
|
||||||
|
|
||||||
['<S-Tab>'] = cmp.mapping(function()
|
-- Previous selection
|
||||||
|
['<Up>'] = cmp.mapping(function()
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item();
|
cmp.select_prev_item();
|
||||||
elseif vim.fn['vsnip#jumpable'](-1) == 1 then
|
|
||||||
feedkey('<Plug>(vsnip-jump-prev)', '');
|
|
||||||
end;
|
end;
|
||||||
end, {
|
end, {
|
||||||
'i',
|
'i',
|
||||||
|
|
Loading…
Reference in a new issue