1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2024-11-13 02:31:13 +00:00
dotfiles/.config/nvim/lua/plugins/cmp.lua

88 lines
1.8 KiB
Lua
Raw Normal View History

2023-04-12 18:09:30 +00:00
local cmp = require("cmp")
2022-10-01 11:46:18 +00:00
local kind_icons = {
Array = "",
Boolean = "",
Class = "",
Codeium = "",
Color = "",
Constant = "",
Constructor = "",
2024-02-16 15:37:22 +00:00
Copilot = "",
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({
mapping = cmp.mapping.preset.insert({
2024-06-07 16:12:31 +00:00
["<C-j>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-Space>"] = cmp.mapping.complete(),
["<C-q>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm(),
-- ["<Tab>"] = cmp.mapping(function(fallback)
-- cmp.select_next_item()
-- end),
2024-06-07 16:12:31 +00:00
["<C-CR>"] = function(fallback)
cmp.abort()
fallback()
end,
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
},
})