nvim: cmp: dwim tab
This commit is contained in:
parent
8cc67ed135
commit
7339958a08
|
@ -17,13 +17,14 @@ packer.use {
|
|||
},
|
||||
config = function()
|
||||
local cmp = require'cmp'
|
||||
if cmp == nil then
|
||||
return
|
||||
end
|
||||
if not cmp then return end
|
||||
local luasnip = require('luasnip')
|
||||
if not luasnip then return end
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
|
@ -37,7 +38,26 @@ packer.use {
|
|||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<End>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = false }),
|
||||
['<tab>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expandable() then
|
||||
luasnip.expand()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.kump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end)
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
|
|
Loading…
Reference in New Issue
Block a user