return { "hrsh7th/nvim-cmp", dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline", "hrsh7th/cmp-nvim-lua", "hrsh7th/cmp-calc", "hrsh7th/cmp-nvim-lsp-signature-help" }, enabled = true, lazy = false, config = function(_, _) local cmp = require("cmp") local mapping = { [""] = function(fallback) if cmp.visible() then cmp.select_next_item( { behavior = cmp.SelectBehavior.Select }) else fallback() end end, [""] = function(fallback) if cmp.visible() then cmp.select_prev_item( { behavior = cmp.SelectBehavior.Select }) else fallback() end end, [""] = function(fallback) if cmp.visible() and cmp.get_active_entry() then cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace }) else fallback() end end } cmp.setup({ snippet = {}, mapping = mapping, sources = cmp.config.sources({ { name = "nvim_lsp" } }, { { name = "buffer" }, { name = "nvim_lua" }, { name = "calc" }, { name = "nvim_lsp_signature_help" }, { name = "path" } }) }) cmp.setup.cmdline("/", { mapping = cmp.mapping.preset.cmdline(), sources = { { name = "buffer" } } }) cmp.setup.cmdline(":", { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = "path" } }, { { name = "cmdline", option = { ignore_cmds = { "Man", "!" } } } }) }) vim.api.nvim_create_autocmd("LspAttach", { callback = function(args) local client = vim.lsp.get_client_by_id(args.data.client_id) if client == nil then return end if client:supports_method('textDocument/completion') then vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = false }) end end }) end }