local cmp = require('cmp') local copt = vim.fn['SpaceVim#layers#autocomplete#get_variable']() -- 1. `auto_completion_return_key_behavior` set the action to perform -- when the `Return`/`Enter` key is pressed. the possible values are: -- - `complete` completes with the current selection -- - `smart` completes with current selection and expand snippet or argvs -- - `nil` -- By default it is `complete`. local feedkey = function(key, mode) vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) end cmp.setup({ mapping = { [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. [''] = cmp.mapping({ i = cmp.mapping.abort(), c = cmp.mapping.close(), }), [''] = function(fallback) if copt.auto_completion_return_key_behavior == 'smart' and vim.fn['neosnippet#expandable_or_jumpable']() == 1 then feedkey('(neosnippet_expand_or_jump)', '') elseif cmp.visible() and copt.auto_completion_return_key_behavior == 'complete' then cmp.select_next_item() else fallback() end end, [''] = function(fallback) if cmp.visible() then cmp.select_prev_item() else fallback() end end, [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }, sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'path' }, { name = 'neosnippet' }, }, { { name = 'buffer' }, }), }) -- Setup lspconfig. local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) -- Replace with each lsp server you've enabled.