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