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" }, { 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({ [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), [""] = cmp.mapping.confirm({ select = true }), }), })