refine completion keybinds
This commit is contained in:
@ -7,7 +7,6 @@ end
|
||||
|
||||
return { 'hrsh7th/nvim-cmp',
|
||||
requires = {
|
||||
'danymat/neogen',
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
'lukas-reineke/cmp-under-comparator' -- better results
|
||||
},
|
||||
@ -26,7 +25,6 @@ return { 'hrsh7th/nvim-cmp',
|
||||
function()
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
local neogen = require('neogen')
|
||||
|
||||
cmp.setup {
|
||||
-- disable when in comments
|
||||
@ -116,54 +114,30 @@ return { 'hrsh7th/nvim-cmp',
|
||||
|
||||
-- mappings
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if #cmp.get_entries() == 1 then
|
||||
["<C-y>"] = cmp.mapping(function()
|
||||
if cmp.get_active_entry() then
|
||||
cmp.confirm({ select = true })
|
||||
elseif cmp.visible() then
|
||||
elseif cmp.visible() and not cmp.get_active_entry() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
if #cmp.get_entries() == 1 then
|
||||
cmp.confirm({ select = true })
|
||||
end
|
||||
elseif neogen.jumpable() then
|
||||
neogen.jump_next()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
end, { "i", "c" }),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
["<C-n>"] = cmp.mapping(function()
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
end
|
||||
end),
|
||||
|
||||
["<C-p>"] = cmp.mapping(function()
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
elseif neogen.jumpable(-1) then
|
||||
neogen.jump_prev()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
['<CR>'] = cmp.mapping {
|
||||
i = function(fallback)
|
||||
if cmp.visible() and cmp.get_active_entry() then
|
||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
s = cmp.mapping.confirm({ select = true }),
|
||||
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true }),
|
||||
},
|
||||
end),
|
||||
|
||||
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
||||
['<ESC>'] = cmp.mapping.close(),
|
||||
["<C-e>"] = cmp.mapping.abort()
|
||||
['<ESC>'] = cmp.mapping.close()
|
||||
}
|
||||
}
|
||||
end
|
||||
|
Reference in New Issue
Block a user