return { 'hrsh7th/nvim-cmp', event = 'InsertEnter', dependencies = { 'L3MON4D3/LuaSnip', 'hrsh7th/cmp-vsnip', 'hrsh7th/vim-vsnip', 'hrsh7th/cmp-nvim-lsp', 'onsails/lspkind.nvim', 'hrsh7th/cmp-nvim-lsp-signature-help' }, config = function() local cmp = require('cmp') cmp.setup { formatting = { fields = { 'kind', 'abbr', 'menu' }, format = function(entry, vim_item) local lspkind = require('lspkind') local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item) local strings = vim.split(kind.kind, "%s", { trimempty = true }) kind.kind = " " .. (strings[1] or "") .. " " kind.menu = " (" .. (strings[2] or "") .. ")" return kind end, }, sources = { { name = 'nvim_lsp' }, { name = 'vsnip' }, { name = 'neorg' }, { name = 'nvim_lsp_signature_help' } }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), --[''] = cmp_action.luasnip_jump_forward(), --[''] = cmp_action.luasnip_jump_backward(), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif vim.fn["vsnip#available"](1) == 1 then feedkey("(vsnip-expand-or-jump)", "") --elseif has_words_before() then -- cmp.complete() else fallback() end end, { "i", "s" }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif vim.fn["vsnip#available"](1) == 1 then feedkey("(vsnip-jump-prev)", "") else fallback() end end, { "i", "s" }), [''] = cmp.mapping.abort(), [''] = cmp.mapping.confirm({ select = false }), }), snippet = { expand = function(args) require('luasnip').lsp_expand(args.body) end }, sorting = { comparators = { cmp.config.compare.length, cmp.config.compare.offset, cmp.config.compare.exact, cmp.config.compare.score, cmp.config.compare.recently_used, cmp.config.compare.locality, cmp.config.compare.kind, cmp.config.compare.sort_text, cmp.config.compare.order, }, }, } end }