80 lines
2.2 KiB
Lua
80 lines
2.2 KiB
Lua
local cmp = require("cmp")
|
|
local luasnip = require("luasnip")
|
|
require("luasnip.loaders.from_vscode").lazy_load()
|
|
|
|
cmp.setup({
|
|
formatting = {
|
|
format = require("lspkind").cmp_format({
|
|
mode = "symbol", -- show only symbol annotations
|
|
maxwidth = 50, -- prevent the popup from showing more than provided characters
|
|
ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead
|
|
symbol_map = {
|
|
Codeium = "",
|
|
},
|
|
}),
|
|
},
|
|
snippet = {
|
|
-- REQUIRED - you must specify a snippet engine
|
|
expand = function(args)
|
|
require("luasnip").lsp_expand(args.body)
|
|
end,
|
|
},
|
|
mapping = cmp.mapping.preset.insert({
|
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
|
["<C-e>"] = cmp.mapping.abort(),
|
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif luasnip.expand_or_jumpable() then
|
|
luasnip.expand_or_jump()
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
elseif luasnip.jumpable(-1) then
|
|
luasnip.jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
}),
|
|
sources = {
|
|
{ name = "async_path", priority = 1 },
|
|
{ name = "buffer", priority = 1 },
|
|
{ name = "luasnip", priority = 2 },
|
|
{ name = "codeium", priority = 3 },
|
|
{ name = "nvim_lsp", priority = 4 },
|
|
},
|
|
})
|
|
|
|
-- Set configuration for specific filetype.
|
|
cmp.setup.filetype("gitcommit", {
|
|
sources = cmp.config.sources({
|
|
{ name = "buffer" },
|
|
}),
|
|
})
|
|
|
|
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
|
cmp.setup.cmdline({ "/", "?" }, {
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
sources = {
|
|
{ name = "buffer" },
|
|
},
|
|
})
|
|
|
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
|
cmp.setup.cmdline(":", {
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
sources = cmp.config.sources({
|
|
{ name = "async_path" },
|
|
}, {
|
|
{ name = "cmdline" },
|
|
}),
|
|
})
|