81 lines
2.6 KiB
VimL
81 lines
2.6 KiB
VimL
" Show completion menu in all cases, and don't select anything
|
|
set completeopt=menu,menuone,noselect
|
|
|
|
lua << EOF
|
|
local cmp = require("cmp")
|
|
local cmp_under_comparator = require("cmp-under-comparator")
|
|
local luasnip = require("luasnip")
|
|
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args)
|
|
luasnip.lsp_expand(args.body)
|
|
end,
|
|
},
|
|
mapping = {
|
|
["<Down>"] = cmp.mapping({
|
|
i = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
|
|
c = function(fallback)
|
|
cmp.close()
|
|
vim.schedule(cmp.suspend())
|
|
fallback()
|
|
end,
|
|
}),
|
|
["<Up>"] = cmp.mapping({
|
|
i = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
|
|
c = function(fallback)
|
|
cmp.close()
|
|
vim.schedule(cmp.suspend())
|
|
fallback()
|
|
end,
|
|
}),
|
|
["<Tab>"] = function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif luasnip.expand_or_jumpable() then
|
|
luasnip.expand_or_jump()
|
|
else
|
|
fallback()
|
|
end
|
|
end,
|
|
["<S-Tab>"] = function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
elseif luasnip.jumpable(-1) then
|
|
luasnip.jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end,
|
|
["<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" }),
|
|
["<C-d>"] = cmp.mapping.scroll_docs(-5),
|
|
["<C-f>"] = cmp.mapping.scroll_docs(5),
|
|
["<C-y>"] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }),
|
|
["<C-e>"] = cmp.mapping.abort(),
|
|
},
|
|
view = {
|
|
entries = "native",
|
|
},
|
|
sources = {
|
|
{ name = "path", priority_weight = 110 },
|
|
{ name = "nvim_lsp", priority_weight = 100 },
|
|
{ name = "nvim_lua", priority_weight = 90 },
|
|
{ name = "luasnip", priority_weight = 80 },
|
|
{ name = "buffer", max_item_count = 5, priority_weight = 50 },
|
|
},
|
|
sorting = {
|
|
comparators = {
|
|
cmp.config.compare.offset,
|
|
cmp.config.compare.exact,
|
|
cmp.config.compare.score,
|
|
cmp_under_comparator.under,
|
|
cmp.config.compare.kind,
|
|
cmp.config.compare.sort_text,
|
|
cmp.config.compare.length,
|
|
cmp.config.compare.order,
|
|
},
|
|
},
|
|
})
|
|
EOF
|