return { -- Autocompletion -- https://github.com/hrsh7th/nvim-cmp { 'hrsh7th/nvim-cmp', event = 'InsertEnter', dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', -- Adds other completion capabilities. -- nvim-cmp does not ship with all sources by default. They are split -- into multiple repos for maintenance purposes. 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-path', 'onsails/lspkind.nvim', { 'zbirenbaum/copilot-cmp', dependencies = { 'zbirenbaum/copilot.lua', }, config = function() require('copilot_cmp').setup() end, }, }, config = function() -- nvim-cmp setup local cmp = require 'cmp' local luasnip = require 'luasnip' local lspkind = require 'lspkind' luasnip.config.setup {} cmp.setup { formatting = { format = lspkind.cmp_format { mode = 'symbol', max_width = 50, symbol_map = { Copilot = '' }, }, }, view = { entries = 'native', }, snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display -- completions whenever it has completion options available. [''] = cmp.mapping.complete(), [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }, [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end, { 'i', 's' }), }, sources = { -- Copilot Source { name = 'copilot', group_index = 2 }, -- Other Sources { name = 'nvim_lsp', group_index = 2 }, { name = 'path', group_index = 2 }, { name = 'luasnip', group_index = 2 }, }, } end, }, }