return { "hrsh7th/nvim-cmp", dependencies = { "hrsh7th/cmp-cmdline", "hrsh7th/cmp-nvim-lsp-document-symbol", -- "hrsh7th/cmp-nvim-lsp-signature-help", { "lukas-reineke/cmp-rg", enabled = vim.fn.exepath "rg" ~= "" }, }, event = { "InsertEnter", "CmdlineEnter" }, opts = function(_, opts) local cmp = require "cmp" if vim.fn.exepath "rg" ~= "" then table.insert(opts.sources, 3, { name = "rg" }) end opts.preselect = cmp.PreselectMode.None opts.mapping = cmp.mapping.preset.insert { [""] = function(fallback) cmp.abort() fallback() end, [""] = cmp.mapping.confirm { select = true }, [""] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, [""] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), [""] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }, -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. } ---@diagnostic disable-next-line: missing-fields cmp.setup.cmdline(":", { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources { { name = "path" }, { name = "cmdline", option = { ignore_cmds = { "Man", "!" }, }, }, }, }) ---@diagnostic disable-next-line: missing-fields cmp.setup.cmdline("/", { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources { { name = "nvim_lsp_document_symbol" }, { name = "buffer" }, }, }) return opts end, }