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 'hrsh7th/cmp-vsnip', 'hrsh7th/vim-vsnip', 'onsails/lspkind.nvim' }, config = function(_, opts) local cmp = require("cmp"); cmp.setup({ snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, }, completion = { completeopt = "menu,menuone,noinsert", }, sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'vsnip' }, { name = 'buffer' }, { name = 'calc' }, { name = 'emoji' }, { name = "path" }, { 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.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), 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 } }) end } }