Files
.dotfiles/config/nvim/lua/plugins/cmp.lua
T
2026-04-23 11:17:45 -05:00

48 lines
1.0 KiB
Lua

local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
vim.snippet.expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = {
['<Tab>'] = function(fallback)
if cmp.visible() then
if not cmp.select_next_item() then
if vim.bo.buftype ~= 'prompt' and has_words_before() then
cmp.complete()
else
fallback()
end
end
else
return vim.cmd(">")
end
end,
['<S-Tab>'] = function(fallback)
if cmp.visible() then
if not cmp.select_prev_item() then
if vim.bo.buftype ~= 'prompt' and has_words_before() then
cmp.complete()
else
fallback()
end
end
else
return vim.cmd("<")
end
end,
['<CR>'] = cmp.mapping.confirm({ select = true }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'buffer' },
})
})