mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
refactor: allow overriding a provider's symbol kinds
This commit is contained in:
parent
df4771ff79
commit
04b51bfbd2
5 changed files with 22 additions and 44 deletions
|
|
@ -63,13 +63,7 @@ return {
|
|||
sources = {
|
||||
compat = { "codeium" },
|
||||
},
|
||||
completion = {
|
||||
menu = {
|
||||
draw = {
|
||||
override_kind_by_source_name = { codeium = "Codeium" },
|
||||
},
|
||||
},
|
||||
},
|
||||
providers = { codeium = { kind = "Codeium" } },
|
||||
},
|
||||
} or nil,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,13 +104,10 @@ return {
|
|||
enabled_providers = { "copilot" },
|
||||
},
|
||||
providers = {
|
||||
copilot = { name = "copilot", module = "blink-cmp-copilot" },
|
||||
},
|
||||
},
|
||||
completion = {
|
||||
menu = {
|
||||
draw = {
|
||||
override_kind_by_source_name = { copilot = "Copilot" },
|
||||
copilot = {
|
||||
name = "copilot",
|
||||
module = "blink-cmp-copilot",
|
||||
kind = "Copilot",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -51,13 +51,7 @@ return {
|
|||
sources = {
|
||||
compat = { "supermaven" },
|
||||
},
|
||||
completion = {
|
||||
menu = {
|
||||
draw = {
|
||||
override_kind_by_source_name = { supermaven = "Supermaven" },
|
||||
},
|
||||
},
|
||||
},
|
||||
providers = { supermaven = { kind = "Supermaven" } },
|
||||
},
|
||||
} or nil,
|
||||
|
||||
|
|
|
|||
|
|
@ -42,13 +42,7 @@ return {
|
|||
sources = {
|
||||
compat = { "cmp_tabnine" },
|
||||
},
|
||||
completion = {
|
||||
menu = {
|
||||
draw = {
|
||||
override_kind_by_source_name = { cmp_tabnine = "TabNine" },
|
||||
},
|
||||
},
|
||||
},
|
||||
providers = { cmp_tabnine = { kind = "TabNine" } },
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ return {
|
|||
completion = {
|
||||
menu = {
|
||||
draw = {
|
||||
override_kind_by_source_name = {},
|
||||
treesitter = true,
|
||||
},
|
||||
},
|
||||
|
|
@ -96,22 +95,22 @@ return {
|
|||
end
|
||||
end
|
||||
|
||||
local override_kind_by_source_name = opts.completion.menu.draw.override_kind_by_source_name or {}
|
||||
local kind = {
|
||||
text = function(ctx)
|
||||
local kind_override = override_kind_by_source_name[ctx.source_name]
|
||||
return kind_override and kind_override or ctx.kind
|
||||
end,
|
||||
highlight = function(ctx)
|
||||
local kind_override = override_kind_by_source_name[ctx.source_name]
|
||||
return kind_override and "BlinkCmpKind" .. kind_override
|
||||
or require("blink.cmp.completion.windows.render.tailwind").get_hl(ctx)
|
||||
or ("BlinkCmpKind" .. ctx.kind)
|
||||
end,
|
||||
}
|
||||
-- check if we need to override symbol kinds
|
||||
for _, provider in pairs(opts.sources.providers or {}) do
|
||||
---@cast provider blink.cmp.SourceProviderConfig|{kind?:string}
|
||||
if provider.kind then
|
||||
require("blink.cmp.types").CompletionItemKind[provider.kind] = provider.kind
|
||||
---@param ctx blink.cmp.Context
|
||||
---@param items blink.cmp.CompletionItem[]
|
||||
provider.transform_items = function(ctx, items)
|
||||
for _, item in ipairs(items) do
|
||||
item.kind = provider.kind or item.kind
|
||||
end
|
||||
return items
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
opts.completion.menu.draw.components =
|
||||
vim.tbl_deep_extend("force", { kind = kind }, opts.completion.menu.draw.components or {})
|
||||
require("blink.cmp").setup(opts)
|
||||
end,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue