local cmp = require("cmp") -- local cmp_buffer = require("cmp_buffer") cmp.setup({ completion = { completeopt = "menu,menuone,noselect", }, snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, }, preselect = cmp.PreselectMode.None, window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.close(), ["C-y"] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }), [""] = cmp.mapping.confirm({ select = true, behaviour = cmp.ConfirmBehavior.Replace }), -- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#super-tab-like-mapping [""] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true, }), [""] = function(fallback) if not cmp.select_next_item() then if vim.bo.buftype ~= "prompt" and has_words_before() then cmp.complete() else fallback() end end end, [""] = function(fallback) if not cmp.select_prev_item() then if vim.bo.buftype ~= "prompt" and has_words_before() then cmp.complete() else fallback() end end end, }), sources = cmp.config.sources({ { name = "copilot", keyword_length = 0 }, { name = "nvim_lsp", keyword_length = 3 }, { name = "buffer", option = { get_bufnrs = function() return vim.api.nvim_list_bufs() end, }, }, { name = "path" }, { name = "calc" }, }), sorting = { comparators = { cmp.config.compare.offset, cmp.config.compare.exact, cmp.config.compare.score, cmp.config.compare.recently_used, -- require("cmp-under-comparator").under, cmp.config.compare.kind, }, }, formatting = { fields = { "kind", "abbr", "menu" }, }, experimental = { ghost_text = true, }, })