feat(cmp): add cmp-cmdline-prompt

This commit is contained in:
2025-10-15 20:39:33 +02:00
parent 5fe67e991e
commit 5bd5b3d745
2 changed files with 46 additions and 0 deletions
+1
View File
@@ -3,6 +3,7 @@
"LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" },
"aerial.nvim": { "branch": "master", "commit": "c7cbbad40c2065fccfd1f1863bb2c08180c0533d" },
"cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" },
"cmp-cmdline-prompt.nvim": { "branch": "main", "commit": "58a56ad589576e2699a1653e8efe724792ee0fa6" },
"cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" },
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
+45
View File
@@ -51,6 +51,7 @@ return {
require("lspkind").init()
end,
},
"teramako/cmp-cmdline-prompt.nvim",
},
config = function()
local cmp = require("cmp")
@@ -183,5 +184,49 @@ return {
},
}),
})
-- for cmdline `input()` prompt
-- see: `:help getcmdtype()`
cmp.setup.cmdline("@", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{
name = "cmdline-prompt",
---@type prompt.Option
option = {
kinds = {
file = cmp.lsp.CompletionItemKind.File,
dir = {
kind = cmp.lsp.CompletionItemKind.Folder,
hl_group = "CmpItemKindEnum",
},
},
},
},
}),
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local item = entry.completion_item
if entry.source.name == "cmdline-prompt" then
vim_item.kind = cmp.lsp.CompletionItemKind[item.kind]
local kind =
lspkind.cmp_format({ mode = "symbol_text" })(
entry,
vim_item
)
local strings =
vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. (strings[1] or "")
kind.menu = " ("
.. (item.data.completion_type or "")
.. ")"
kind.menu_hl_group = kind.kind_hl_group
return kind
else
return vim_item
end
end,
},
})
end,
}