vim.pack.add({ 'https://github.com/hrsh7th/nvim-cmp', 'https://github.com/hrsh7th/cmp-nvim-lsp', 'https://github.com/hrsh7th/cmp-buffer', 'https://github.com/hrsh7th/cmp-path', 'https://github.com/hrsh7th/cmp-cmdline', 'https://github.com/hrsh7th/cmp-nvim-lua', }) local cmp = require('cmp') cmp.setup { completion = { completeopt = 'menu,menuone,noinsert', }, experimental = { ghost_text = true, }, mapping = { [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true, }), }, formatting = { format = function(entry, vim_item) vim_item.menu = ({ buffer = '[Buf]', luasnip = '[Snips]', nvim_lsp = '[LSP]', nvim_lua = '[Lua]', })[entry.source.name] return vim_item end, field = { 'abbr', 'kind', 'menu' } }, sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' }, { name = 'render-markdown' }, }, { { name = 'buffer' }, }) } cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = 'path' }, }, { { name = 'cmdline' }, }) }) cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'buffer' } } })