Archived
0
0
Fork 0
This repository has been archived on 2024-02-06. You can view files and clone it, but cannot push or open issues or pull requests.
neovim-config/lua/plugins/configs/cmp.lua

57 lines
1.3 KiB
Lua
Raw Permalink Normal View History

local cmp = require("cmp")
local lspkind = require("lspkind")
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
completion = { completeopt = "menu,menuone,noinsert", keyword_length = 1 },
sources = {
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "vsnip" },
{ name = "buffer" },
{ name = "path" },
2022-11-23 06:33:38 +00:00
{ name = "crates" },
},
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
documentation = {
border = { "", "", "", "", "", "", "", "" },
},
},
experimental = {
ghost_text = true,
native_menu = false,
},
formatting = {
fields = { "abbr", "kind", "menu" },
format = lspkind.cmp_format({
mode = "symbol_text",
maxwidth = 50,
before = function(entry, vim_item)
vim_item.menu = ({
nvim_lsp = "[LSP]",
nvim_lua = "[NVIM_LUA]",
vsnip = "[SNIPPET]",
buffer = "[BUFFER]",
path = "[PATH]",
})[entry.source.name]
return vim_item
end,
}),
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
})