From aa5717f00fd14430c80939a68d7107c26de6e554 Mon Sep 17 00:00:00 2001 From: Mohammad Reza Karimi Date: Tue, 20 Jan 2026 15:55:27 -0500 Subject: first commit --- lua/mo/cmp.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lua/mo/cmp.lua (limited to 'lua/mo/cmp.lua') diff --git a/lua/mo/cmp.lua b/lua/mo/cmp.lua new file mode 100644 index 0000000..be6fb95 --- /dev/null +++ b/lua/mo/cmp.lua @@ -0,0 +1,42 @@ +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" }, + }), +}) -- cgit v1.2.3-71-gdd5e