unix-config/.config/nvim/plugin/cmp.lua
2024-08-16 21:55:29 +10:00

34 lines
731 B
Lua

local cmp = require'cmp'
local cmpStatus, cmp = pcall(require, "cmp")
if (not cmpStatus) then
print("cmp is not installed")
return
end
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
local entry = cmp.get_selected_entry()
if not entry then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
else
cmp.confirm()
end
else
fallback()
end
end, {"i","s","c",}),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'buffer' },
})
})