2023-04-12 18:09:30 +00:00
|
|
|
local cmp = require("cmp")
|
2022-10-01 11:46:18 +00:00
|
|
|
|
|
|
|
local kind_icons = {
|
2023-10-08 18:01:33 +00:00
|
|
|
Array = " ",
|
|
|
|
Boolean = " ",
|
|
|
|
Class = " ",
|
|
|
|
Codeium = " ",
|
|
|
|
Color = " ",
|
|
|
|
Constant = " ",
|
|
|
|
Constructor = " ",
|
2024-02-16 15:37:22 +00:00
|
|
|
Copilot = " ",
|
2023-10-08 18:01:33 +00:00
|
|
|
Enum = " ",
|
|
|
|
EnumMember = " ",
|
|
|
|
Event = " ",
|
|
|
|
Field = " ",
|
|
|
|
File = " ",
|
|
|
|
Folder = " ",
|
|
|
|
Function = " ",
|
|
|
|
Interface = " ",
|
|
|
|
Key = " ",
|
|
|
|
Keyword = " ",
|
|
|
|
Method = " ",
|
|
|
|
Module = " ",
|
|
|
|
Namespace = " ",
|
|
|
|
Null = " ",
|
|
|
|
Number = " ",
|
|
|
|
Object = " ",
|
|
|
|
Operator = " ",
|
|
|
|
Package = " ",
|
|
|
|
Property = " ",
|
|
|
|
Reference = " ",
|
|
|
|
String = " ",
|
|
|
|
Struct = " ",
|
|
|
|
Text = " ",
|
|
|
|
TypeParameter = " ",
|
|
|
|
Unit = " ",
|
|
|
|
Value = " ",
|
|
|
|
Variable = " ",
|
2022-10-01 11:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cmp.setup({
|
2024-06-13 18:44:42 +00:00
|
|
|
mapping = {
|
|
|
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
|
|
|
["<C-n>"] = cmp.mapping.select_next_item(),
|
|
|
|
["<C-k>"] = cmp.mapping.scroll_docs(-1),
|
|
|
|
["<C-j>"] = cmp.mapping.scroll_docs(1),
|
2024-06-07 16:12:31 +00:00
|
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
2024-06-13 18:44:42 +00:00
|
|
|
["<C-q>"] = cmp.mapping.close(),
|
|
|
|
["<CR>"] = cmp.mapping.confirm({
|
|
|
|
behavior = cmp.ConfirmBehavior.Insert,
|
|
|
|
select = true,
|
|
|
|
}),
|
|
|
|
|
|
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_next_item()
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end, { "i", "s" }),
|
|
|
|
|
|
|
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_prev_item()
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end, { "i", "s" }),
|
|
|
|
},
|
|
|
|
|
2022-10-01 11:46:18 +00:00
|
|
|
formatting = {
|
|
|
|
fields = { "kind", "abbr", "menu" },
|
|
|
|
format = function(entry, vim_item)
|
|
|
|
vim_item.kind = kind_icons[vim_item.kind]
|
|
|
|
vim_item.menu = ({
|
2022-10-23 10:35:25 +00:00
|
|
|
nvim_lsp = "[lsp]",
|
|
|
|
buffer = "[local]",
|
2024-02-12 19:46:40 +00:00
|
|
|
copilot = "[AI]",
|
2022-10-01 11:46:18 +00:00
|
|
|
path = "",
|
|
|
|
emoji = "",
|
|
|
|
})[entry.source.name]
|
|
|
|
return vim_item
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
sources = {
|
|
|
|
{ name = "nvim_lsp" },
|
|
|
|
{ name = "buffer" },
|
|
|
|
{ name = "path" },
|
2024-02-12 19:46:40 +00:00
|
|
|
{ name = "copilot" },
|
2022-10-01 11:46:18 +00:00
|
|
|
},
|
|
|
|
confirm_opts = {
|
|
|
|
behavior = cmp.ConfirmBehavior.Replace,
|
|
|
|
select = false,
|
|
|
|
},
|
|
|
|
window = {
|
|
|
|
completion = cmp.config.window.bordered(),
|
|
|
|
documentation = cmp.config.window.bordered(),
|
|
|
|
},
|
|
|
|
experimental = {
|
2023-05-12 15:16:01 +00:00
|
|
|
ghost_text = { enabled = true },
|
2022-10-01 11:46:18 +00:00
|
|
|
},
|
|
|
|
})
|