return { { "hrsh7th/nvim-cmp", version = false, event = "InsertEnter", dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-nvim-lua", "hrsh7th/cmp-path", "saadparwaiz1/cmp_luasnip", "hrsh7th/cmp-nvim-lsp-signature-help", "onsails/lspkind.nvim", }, config = function() vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) local luasnip = require("luasnip") local cmp = require("cmp") local border_opts = { border = { { "╭", "CmpDocBorder" }, { "─", "CmpDocBorder" }, { "╮", "CmpDocBorder" }, { "│", "CmpDocBorder" }, { "╯", "CmpDocBorder" }, { "─", "CmpDocBorder" }, { "╰", "CmpDocBorder" }, { "│", "CmpDocBorder" }, }, winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None", } ---@diagnostic disable: missing-fields cmp.setup({ formatting = { preselect = cmp.PreselectMode.None, fields = { "abbr", "kind", "menu", }, format = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 150, ellipsis_char = "...", before = function(entry, vim_item) vim_item.menu = ({ nvim_lsp = "[LSP]", buffer = "[Buffer]", })[entry.source.name] return vim_item end, }), }, completion = { completeopt = "menu,menuone,noinsert", }, snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, view = { docs = { auto_open = false, }, }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), [""] = cmp.mapping.confirm({ behavior = cmp.SelectBehavior.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.expand_or_jumpable(-1) then luasnip.jump(-1) else fallback() end end, { "i", "s" }), [""] = function() if cmp.visible_docs() then cmp.close_docs() else cmp.open_docs() end end, }), sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "nvim_lsp_signature_help" }, { name = "luasnip" }, { name = "buffer" }, { name = "path" }, }), window = { scrollbar = false, completion = cmp.config.window.bordered(border_opts), documentation = cmp.config.window.bordered(border_opts), }, }) ---@diagnostic enable: missing-fields end, }, }