return { 'hrsh7th/nvim-cmp', dependencies = { 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-path', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-calc', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-nvim-lsp-signature-help', 'saadparwaiz1/cmp_luasnip', 'onsails/lspkind.nvim', }, event = { 'InsertEnter', 'CmdlineEnter' }, config = function() local cmp = require 'cmp' cmp.setup { snippet = { expand = function(args) require('luasnip').lsp_expand(args.body) end, }, view = { entries = { name = 'custom', -- can be "custom", "wildmenu" or "native" -- separator = ' | ', selection_order = 'near_cursor', }, }, -- completion = { -- autocomplete = { 'TextChanged', 'CmdlineChanged', 'TextChangedP' }, -- -- autocomplete = false, -- }, window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, experimental = { ghost_text = { hl_group = { "Comment" }, }, }, mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() else fallback() end end, { 'i', 's' }), [''] = cmp.mapping.confirm { select = false }, }, sources = cmp.config.sources({ { name = 'luasnip' }, { name = 'nvim_lsp' }, { name = 'nvim_lsp_signature_help' }, }, { { name = 'path' }, { name = 'calc' }, { name = 'buffer' }, }), formatting = { format = require 'lspkind'.cmp_format({ mode = 'symbol_text', -- show only symbol annotations maxwidth = 50, -- 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 -- maxwidth = function() return math.floor(0.45 * vim.o.columns) end, 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 }) }, } cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'buffer' }, }, }) cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = 'path' }, }, { { name = 'cmdline' }, }), }) end, }