-- Completion local completion = {} local cmp = require('cmp') local lspkind = require('lspkind') vim.opt.shortmess:append 'c' cmp.setup({ snippet = { expand = function(args) require('luasnip').lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, [""] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), [''] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }), [''] = cmp.mapping({ i = cmp.mapping.abort(), c = cmp.mapping.close(), }), [''] = cmp.mapping.confirm({ select = true }), }), sources = cmp.config.sources({ { name = 'nvim_lua' }, { name = 'nvim_lsp' }, { name = 'path' }, { name = 'luasnip' }, { name = 'nvim_lsp_signature_help' }, }, { { name = 'buffer', keyword_length = 5 }, }), formatting = { format = lspkind.cmp_format { with_text = true, menu = { buffer = "[buf]", nvim_lsp = "[LSP]", nvim_lua = "[api]", path = "[path]", luasnip = "[snip]", } } } }) -- Use buffer source for `/` (basically search words in buffer) cmp.setup.cmdline('/', { sources = { { name = 'buffer' } } }) -- Use cmdline & path source for ':' cmp.setup.cmdline(':', { sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }) }) -- autopair require('nvim-autopairs').setup {} return completion