return { { 'hrsh7th/nvim-cmp', event = 'VeryLazy', dependencies = { 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-path', 'hrsh7th/cmp-nvim-lsp', 'ray-x/cmp-treesitter', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', }, config = function() local cmp = require('cmp') cmp.setup { snippet = { expand = function(args) require('luasnip').lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, [''] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, [''] = cmp.mapping.confirm { select = true, behavior = cmp.SelectBehavior.Insert }, }, sources = cmp.config.sources({ { name = 'nvim_lsp', keyword_length = 1 }, { name = 'luasnip' }, { name = 'buffer' }, { name = 'path' }, { name = 'treesitter', keyword_length = 3 }, }), } cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'buffer' }, }, }) cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = 'path' }, { name = 'buffer' }, { name = 'cmdline' }, }), matching = { disallow_symbol_nonprefix_matching = false }, }) end, }, { 'L3MON4D3/LuaSnip', event = 'VeryLazy', dependencies = { 'rafamadriz/friendly-snippets' }, config = function() local ls = require('luasnip') ls.config.set_config { history = true, updateevents = 'TextChanged, TextChangedI', } require('luasnip.loaders.from_vscode').lazy_load() vim.keymap.set({ 'i', 's' }, '', function() if ls.expand_or_jumpable() then ls.expand_or_jump() end end, { silent = true }) vim.keymap.set({ 'i', 's' }, '', function() if ls.jumpable(-1) then ls.jump(-1) end end, { silent = true }) vim.keymap.set({ 'i', 's' }, '', function() if ls.choice_active() then ls.change_choice(1) end end, { silent = true }) end, }, }