return { { 'hrsh7th/nvim-cmp', lazy = false, priority = 100, dependencies = { 'onsails/lspkind.nvim', 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-path', 'hrsh7th/cmp-buffer', { 'L3MON4D3/LuaSnip', build = 'make install_jsregexp' }, 'saadparwaiz1/cmp_luasnip', 'rafamadriz/friendly-snippets', 'zbirenbaum/copilot-cmp', }, config = function() vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } vim.opt.shortmess:append 'c' local cmp = require 'cmp' local lspkind = require 'lspkind' lspkind.init() cmp.setup { sources = { { name = 'copilot' }, { name = 'luasnip' }, { name = 'nvim_lsp' }, { name = 'path' }, { name = 'buffer' }, }, mapping = { [''] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, [''] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, [''] = cmp.mapping( cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Insert, select = true, }, { 'i', 'c' } ), }, -- Enable luasnip to handle snippet expansion for nvim-cmp snippet = { expand = function(args) require('luasnip').lsp_expand(args.body) end, }, formatting = { expandable_indicator = true, fields = { 'abbr', 'kind' }, format = lspkind.cmp_format { mode = 'symbol', -- show only symbol annotations maxwidth = 20, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) show_labelDetails = true, -- show labelDetails in menu. Disabled by default -- The function below will be called before any actual modifications from lspkind -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) -- before = function(entry, vim_item) -- return vim_item -- end, }, }, } -- Setup up vim-dadbod cmp.setup.filetype({ 'sql' }, { sources = { { name = 'vim-dadbod-completion' }, { name = 'buffer' }, }, }) local ls = require 'luasnip' ls.config.set_config { history = false, updateevents = 'TextChanged,TextChangedI', } for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/custom/snippets/*.lua', true)) do loadfile(ft_path)() end 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 }) require('luasnip/loaders/from_vscode').lazy_load() end, }, }