return { { "hrsh7th/nvim-cmp", dependencies = { -- extra completion plugins "hrsh7th/cmp-cmdline", "hrsh7th/cmp-path", "hrsh7th/cmp-buffer", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-calc", "hrsh7th/cmp-emoji", "kdheepak/cmp-latex-symbols", -- snippets "saadparwaiz1/cmp_luasnip", "L3MON4D3/LuaSnip", "onsails/lspkind.nvim", }, config = function(_, _) local cmp = require("cmp") cmp.setup({ window = { completion = { border = "none", scrollbar = false, winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,Search:None", }, documentation = { border = "none", scrollbar = false, winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,Search:None", }, }, snippet = { expand = function(args) require("luasnip").lsp_expand(args.body) end, }, completion = { completeopt = "longest,menuone,noinsert,noselect", }, sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "nvim_lsp_signature_help" }, { name = "luasnip" }, { name = "buffer" }, { name = "path" }, }, { { name = "calc" }, { name = "emoji" }, { name = "cmdline" }, { name = "latex_symbols" }, }), mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), [""] = cmp.mapping({ i = function(fallback) if cmp.visible() and cmp.get_active_entry() then cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) else fallback() end end, s = cmp.mapping.confirm({ select = true }), c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), }), }), formatting = { fields = { "kind", "abbr", "menu" }, format = function(entry, item) local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, item) local strings = vim.split(kind.kind, "%s", { trimempty = true }) kind.kind = (strings[1] or "") .. " " kind.menu = " (" .. (strings[2] or "") .. ")" return kind end, }, experimental = { ghost_text = { hl_group = "NonText", }, }, }) end, }, }