You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.0 KiB
88 lines
2.0 KiB
local cmp = require("cmp") |
|
|
|
cmp.setup({ |
|
snippet = { |
|
expand = function(args) |
|
vim.fn["vsnip#anonymous"](args.body) |
|
end, |
|
}, |
|
|
|
mapping = cmp.mapping.preset.insert({ |
|
["<C-p>"] = cmp.mapping.select_prev_item(), |
|
["<C-n>"] = cmp.mapping.select_next_item(), |
|
|
|
["<C-f>"] = cmp.mapping.scroll_docs(4), |
|
["<C-b>"] = cmp.mapping.scroll_docs(-4), |
|
|
|
["<C-Space>"] = cmp.mapping.complete(), |
|
["<C-e>"] = cmp.mapping.abort(), |
|
|
|
["<CR>"] = cmp.mapping.confirm({ |
|
behavior = cmp.ConfirmBehavior.Insert, |
|
select = false, |
|
}), |
|
|
|
["<Tab>"] = cmp.mapping(function(fallback) |
|
if cmp.visible() then |
|
cmp.select_next_item() |
|
elseif vim.fn == 1 then |
|
vim.fn.feedkeys( |
|
vim.api.nvim_replace_termcodes("<Plug>(vsnip-jump-next)", true, true, true), |
|
"" |
|
) |
|
else |
|
fallback() |
|
end |
|
end, { "i", "s" }), |
|
|
|
["<S-Tab>"] = cmp.mapping(function(fallback) |
|
if cmp.visible() then |
|
cmp.select_prev_item() |
|
elseif vim.fn["vsnip#jumpable"](-1) == 1 then |
|
vim.fn.feedkeys( |
|
vim.api.nvim_replace_termcodes("<Plug>(vsnip-jump-prev)", true, true, true), |
|
"" |
|
) |
|
else |
|
fallback() |
|
end |
|
end, { "i", "s" }), |
|
}), |
|
|
|
sources = cmp.config.sources({ |
|
{ name = "nvim_lsp", keyword_length = 2 }, |
|
{ name = "path" }, |
|
{ name = "vsnip", keyword_length = 2 }, |
|
}, { |
|
{ name = "buffer", keyword_length = 5 }, |
|
}), |
|
|
|
window = { |
|
completion = cmp.config.window.bordered(), |
|
documentation = cmp.config.window.bordered(), |
|
}, |
|
|
|
formatting = { |
|
fields = { "abbr", "kind", "menu" }, |
|
format = function(entry, item) |
|
local menu_icon = { |
|
nvim_lsp = "λ", |
|
vsnip = "⋗", |
|
buffer = "Ω", |
|
path = "•", |
|
} |
|
|
|
item.menu = menu_icon[entry.source.name] or entry.source.name |
|
return item |
|
end, |
|
}, |
|
|
|
preselect = cmp.PreselectMode.None, |
|
|
|
completion = { |
|
completeopt = "menu,menuone,noinsert,noselect", |
|
}, |
|
}) |
|
|
|
vim.o.completeopt = "menu,menuone,noinsert,noselect" |
|
|
|
|