1
0
Fork 0

nvim: cmp: dwim tab

This commit is contained in:
tastytea 2022-08-12 19:19:20 +02:00
parent 8cc67ed135
commit 7339958a08
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
1 changed files with 25 additions and 5 deletions

View File

@ -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' },