local cmp = require('cmp') cmp.setup({ sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, }, mapping = { [''] = cmp.mapping.confirm({ select = false }), [''] = cmp.mapping.abort(), [''] = cmp.mapping.select_prev_item({ behavior = 'select' }), [''] = cmp.mapping.select_next_item({ behavior = 'select' }), [''] = cmp.mapping.select_prev_item({ behavior = 'insert' }), [''] = cmp.mapping.select_next_item({ behavior = 'insert' }), [''] = cmp.mapping(function() if cmp.visible() then cmp.select_prev_item({ behavior = 'insert' }) else cmp.complete() end end), [''] = cmp.mapping(function() if cmp.visible() then cmp.select_next_item({ behavior = 'insert' }) else cmp.complete() end end), }, snippet = { expand = function(args) require('luasnip').lsp_expand(args.body) end, }, }) -- If you want insert `(` after select function or method item local cmp_autopairs = require('nvim-autopairs.completion.cmp') cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done() )