-- ~/.config/nvim/lua/custom/plugins/completion.lua return { -- Completion framework { 'hrsh7th/nvim-cmp', event = 'InsertEnter', config = function() local cmp = require 'cmp' cmp.setup { snippet = { expand = function(args) vim.fn['vsnip#anonymous'](args.body) end, }, mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), [''] = cmp.mapping.confirm { select = true }, [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif vim.fn == 1 then vim.fn.feedkeys(vim.api.nvim_replace_termcodes('(vsnip-expand-or-jump)', true, true, true), '') else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif vim.fn['vsnip#jumpable'](-1) == 1 then vim.fn.feedkeys(vim.api.nvim_replace_termcodes('(vsnip-jump-prev)', true, true, true), '') else fallback() end end, { 'i', 's' }), }, sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'vsnip' }, }, { { name = 'buffer' }, }), } end, }, -- LSP completion source { 'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp' }, -- Buffer completion source { 'hrsh7th/cmp-buffer', after = 'nvim-cmp' }, -- Path completion source { 'hrsh7th/cmp-path', after = 'nvim-cmp' }, -- Snippet completion source { 'hrsh7th/cmp-vsnip', after = 'nvim-cmp' }, -- Snippet engine { 'hrsh7th/vim-vsnip', event = 'InsertEnter' }, }