return { { "hrsh7th/nvim-cmp", lazy = false, priority = 100, dependencies = { "onsails/lspkind.nvim", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-path", "hrsh7th/cmp-buffer", "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip", }, opts = function(_, opts) opts.sources = opts.sources or {} table.insert(opts.sources, { name = "lazydev", group_index = 0, }) end, config = function() vim.opt.completeopt = { "menu", "menuone", "noselect" } -- some nice cmp icons local lspkind = require("lspkind") lspkind.init({}) local cmp = require("cmp") cmp.setup({ mapping = cmp.mapping.preset.insert({ -- `Enter` key to confirm completion [""] = cmp.mapping.confirm({ select = false }), -- `Esc` key to close the menu [""] = cmp.mapping.abort(), -- Ctrl+Space to trigger completion menu [""] = cmp.mapping.complete(), -- Scroll up and down in the completion documentation -- [""] = cmp.mapping.scroll_docs(-4), -- [""] = cmp.mapping.scroll_docs(4), }), sources = cmp.config.sources({ { name = "nvim_lsp", entry_filter = function(entry, ctx) -- 1 is the Text entry from LSP specs -- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItemKind if entry:get_kind() == 1 then return false end return true end, }, { name = "path" }, -- { name = "buffer" }, }), snippet = { expand = function(args) require("luasnip").lsp_expand(args.body) end, }, formatting = { format = lspkind.cmp_format({}), }, }) end, }, }