nvim/lua/plugin/cmp.lua

35 lines
824 B
Lua
Raw Normal View History

2024-05-27 16:35:03 +02:00
local cmp = require('cmp')
cmp.setup({
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
mapping = {
['<CR>'] = cmp.mapping.confirm({ select = false }),
['<C-e>'] = cmp.mapping.abort(),
['<Up>'] = cmp.mapping.select_prev_item({ behavior = 'select' }),
['<Down>'] = cmp.mapping.select_next_item({ behavior = 'select' }),
['<Tab>'] = cmp.mapping.select_next_item({ behavior = 'select' }),
['<C-p>'] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item({ behavior = 'insert' })
else
cmp.complete()
end
end),
['<C-n>'] = cmp.mapping(function()
if cmp.visible() then
cmp.select_next_item({ behavior = 'insert' })
else
cmp.complete()
end
end),
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
})