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