dotfiles/nvim/lua/completion.lua
2022-10-05 17:19:12 -04:00

41 lines
777 B
Lua

local cmp = require('cmp')
cmp.setup {
mapping = {
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Insert,
select = true,
},
['<Up>'] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end,
['<Down>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end,
},
sources = {
{ name = 'neorg' },
{ name = 'nvim_lua' },
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
{ name = 'buffer' },
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end
},
}