return { "hrsh7th/nvim-cmp", version = false, -- last release is way too old event = "InsertEnter", dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "onsails/lspkind.nvim" }, config = function() local cmp = require("cmp") local lspkind = require("lspkind") cmp.setup({ sources = { { name = "nvim_lsp" } }, formatting = { fields = { 'abbr', 'icon', 'kind', 'menu' }, format = lspkind.cmp_format({ maxwidth = { -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) -- can also be a function to dynamically calculate max width such as -- menu = function() return math.floor(0.45 * vim.o.columns) end, menu = 50, -- leading text (labelDetails) abbr = 50, -- actual suggestion item }, ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) show_labelDetails = true, -- show labelDetails in menu. Disabled by default -- The function below will be called before any actual modifications from lspkind -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) before = function (entry, vim_item) return vim_item end }) }, mapping = cmp.mapping.preset.insert({ -- Navigate between completion items [''] = cmp.mapping.select_prev_item({behavior = 'select'}), [''] = cmp.mapping.select_next_item({behavior = 'select'}), -- `Enter` key to confirm completion [''] = cmp.mapping.confirm({select = false}), -- Ctrl+Space to trigger completion menu [''] = cmp.mapping.complete(), -- Scroll up and down in the completion documentation [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), }), snippet = { expand = function(args) vim.snippet.expand(args.body) end, } }) end, main = "lazyvim.util.cmp", }