49 lines
1.1 KiB
Lua
49 lines
1.1 KiB
Lua
local cmp = require("cmp")
|
|
local cmp_buffer = require("cmp_buffer")
|
|
|
|
cmp.setup({
|
|
completion = {
|
|
completeopt = "menu,menuone,noinsert",
|
|
},
|
|
snippet = {
|
|
expand = function(args)
|
|
vim.fn["vsnip#anonymous"](args.body)
|
|
end,
|
|
},
|
|
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 = {
|
|
function(...)
|
|
return cmp_buffer:compare_locality(...)
|
|
end,
|
|
},
|
|
},
|
|
view = {
|
|
entries = "native",
|
|
},
|
|
experimental = {
|
|
ghost_text = true,
|
|
},
|
|
})
|