2023-05-07 14:07:04 +02:00
|
|
|
-- Show completion menu in all cases, and don't select anything
|
|
|
|
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
|
|
|
|
2022-03-04 16:54:40 +01:00
|
|
|
local cmp = require("cmp")
|
2022-03-07 15:27:57 +01:00
|
|
|
local cmp_under_comparator = require("cmp-under-comparator")
|
2022-03-07 18:08:54 +01:00
|
|
|
local luasnip = require("luasnip")
|
2022-03-04 16:54:40 +01:00
|
|
|
|
|
|
|
cmp.setup({
|
2022-03-07 18:08:54 +01:00
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
luasnip.lsp_expand(args.body)
|
|
|
|
end,
|
|
|
|
},
|
2022-03-07 14:50:59 +01:00
|
|
|
mapping = {
|
2022-03-07 18:08:54 +01:00
|
|
|
["<Tab>"] = function(fallback)
|
2022-03-07 21:57:59 +01:00
|
|
|
if luasnip.expand_or_jumpable() then
|
2022-03-07 18:08:54 +01:00
|
|
|
luasnip.expand_or_jump()
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
["<S-Tab>"] = function(fallback)
|
2022-03-07 21:57:59 +01:00
|
|
|
if luasnip.jumpable(-1) then
|
2022-03-07 18:08:54 +01:00
|
|
|
luasnip.jump(-1)
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end,
|
2022-03-07 14:50:59 +01:00
|
|
|
["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), { "i", "c" }),
|
|
|
|
["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), { "i", "c" }),
|
2023-05-06 19:58:30 +02:00
|
|
|
["<C-d>"] = cmp.mapping.scroll_docs(-5),
|
2022-03-07 17:42:15 +01:00
|
|
|
["<C-f>"] = cmp.mapping.scroll_docs(5),
|
2022-03-07 14:50:59 +01:00
|
|
|
["<C-y>"] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }),
|
|
|
|
["<C-e>"] = cmp.mapping.abort(),
|
|
|
|
},
|
2022-03-06 11:15:38 +01:00
|
|
|
view = {
|
|
|
|
entries = "native",
|
|
|
|
},
|
2022-03-04 16:54:40 +01:00
|
|
|
sources = {
|
2023-08-07 17:37:35 +02:00
|
|
|
{ name = "async_path", priority_weight = 110 },
|
2022-03-06 11:53:48 +01:00
|
|
|
{ name = "nvim_lsp", priority_weight = 100 },
|
|
|
|
{ name = "nvim_lua", priority_weight = 90 },
|
2022-03-07 18:08:54 +01:00
|
|
|
{ name = "luasnip", priority_weight = 80 },
|
2022-03-06 11:54:21 +01:00
|
|
|
{ name = "buffer", max_item_count = 5, priority_weight = 50 },
|
2022-03-06 11:53:48 +01:00
|
|
|
},
|
|
|
|
sorting = {
|
2022-03-07 21:02:30 +01:00
|
|
|
priority_weight = 100,
|
2022-03-06 11:53:48 +01:00
|
|
|
comparators = {
|
|
|
|
cmp.config.compare.offset,
|
|
|
|
cmp.config.compare.exact,
|
|
|
|
cmp.config.compare.score,
|
2022-03-07 15:27:57 +01:00
|
|
|
cmp_under_comparator.under,
|
2022-03-06 11:53:48 +01:00
|
|
|
cmp.config.compare.kind,
|
|
|
|
cmp.config.compare.sort_text,
|
|
|
|
cmp.config.compare.length,
|
|
|
|
cmp.config.compare.order,
|
|
|
|
},
|
2022-03-04 16:54:40 +01:00
|
|
|
},
|
2022-05-19 14:53:05 +02:00
|
|
|
experimental = {
|
|
|
|
ghost_text = true,
|
|
|
|
},
|
2022-03-04 16:54:40 +01:00
|
|
|
})
|