nvim/lua/plugins/cmp.lua
2023-11-07 21:32:05 +01:00

46 lines
1.4 KiB
Lua

return {
'hrsh7th/nvim-cmp',
dependencies = {
{'hrsh7th/cmp-nvim-lsp'},
{'hrsh7th/cmp-nvim-lua'},
{'L3MON4D3/LuaSnip'},
},
config = function()
local cmp = require('cmp')
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'nvim_lua' },
{ name = 'luasnip' },
},
mapping = cmp.mapping.preset.insert({
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end),
['<C-e>'] = cmp.mapping.abort(),
['<C-space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm({ select = false }),
}),
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
})
end
}