vim.cmd([[ packadd nvim-cmp ]]) local cmp = require("cmp") local icons = require("mini.icons") local kinds = require("mo.kinds") local minisnippets = require("mini.snippets") cmp.setup({ view = { entries = "native" }, formatting = { format = function(entry, vim_item) if entry.source.name == "nvim_lsp" and vim_item.kind ~= nil then local icon, _, _ = icons.get("lsp", vim_item.kind) vim_item.kind = string.format("%s %s", icon, kinds[vim_item.kind]) end return vim_item end, }, snippet = { expand = function(args) local insert = minisnippets.config.expand.insert or minisnippets.default_insert insert({ body = args.body }) -- Insert at cursor cmp.resubscribe({ "TextChangedI", "TextChangedP" }) require("cmp.config").set_onetime({ sources = {} }) end, }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), sources = cmp.config.sources({ { name = "nvim_lsp" }, }, { { name = "path" }, { name = "buffer" }, }), })