diff options
| author | Mohammad Reza Karimi <m.r.karimi.j@gmail.com> | 2026-01-20 15:55:27 -0500 |
|---|---|---|
| committer | Mohammad Reza Karimi <m.r.karimi.j@gmail.com> | 2026-01-20 15:55:27 -0500 |
| commit | aa5717f00fd14430c80939a68d7107c26de6e554 (patch) | |
| tree | 784e99d9b018e0554369c41cb33e2e195e28d3c6 /lua/mo/cmp.lua | |
first commit
Diffstat (limited to 'lua/mo/cmp.lua')
| -rw-r--r-- | lua/mo/cmp.lua | 42 |
1 files changed, 42 insertions, 0 deletions
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({ + ["<C-b>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-Space>"] = cmp.mapping.complete(), + ["<C-e>"] = cmp.mapping.abort(), + ["<C-y>"] = 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" }, + }), +}) |
