dotfiles/vim/lua/nvim_cmp_config.lua

57 lines
1.4 KiB
Lua
Raw Normal View History

2023-09-19 05:21:43 +00:00
local cmp = require("cmp")
2023-09-21 14:00:41 +00:00
-- local cmp_buffer = require("cmp_buffer")
cmp.setup({
2023-09-19 05:21:43 +00:00
completion = {
2023-09-21 14:00:41 +00:00
completeopt = "menu,menuone,noinsert,noselect",
2023-09-19 05:21:43 +00:00
},
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
2023-09-21 14:00:41 +00:00
preselect = cmp.PreselectMode.None,
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
2023-09-19 05:21:43 +00:00
mapping = cmp.mapping.preset.insert({
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["C-y"] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }),
["<CR>"] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }),
}),
sources = cmp.config.sources({
{ name = "copilot", keyword_length = 0 },
{ name = "nvim_lsp", keyword_length = 3 },
{
name = "buffer",
option = {
get_bufnrs = function()
return vim.api.nvim_list_bufs()
end,
},
},
{ name = "path" },
{ name = "calc" },
}),
sorting = {
comparators = {
2023-09-21 14:00:41 +00:00
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
cmp.config.compare.recently_used,
-- require("cmp-under-comparator").under,
cmp.config.compare.kind,
2023-09-19 05:21:43 +00:00
},
},
2023-09-21 14:00:41 +00:00
formatting = {
fields = { "kind", "abbr", "menu" },
2023-09-19 05:21:43 +00:00
},
experimental = {
ghost_text = true,
},
})