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 = {
|
sources = {
|
||||||
compat = { "codeium" },
|
compat = { "codeium" },
|
||||||
},
|
},
|
||||||
completion = {
|
providers = { codeium = { kind = "Codeium" } },
|
||||||
menu = {
|
|
||||||
draw = {
|
|
||||||
override_kind_by_source_name = { codeium = "Codeium" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
} or nil,
|
} or nil,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,13 +104,10 @@ return {
|
||||||
enabled_providers = { "copilot" },
|
enabled_providers = { "copilot" },
|
||||||
},
|
},
|
||||||
providers = {
|
providers = {
|
||||||
copilot = { name = "copilot", module = "blink-cmp-copilot" },
|
copilot = {
|
||||||
},
|
name = "copilot",
|
||||||
},
|
module = "blink-cmp-copilot",
|
||||||
completion = {
|
kind = "Copilot",
|
||||||
menu = {
|
|
||||||
draw = {
|
|
||||||
override_kind_by_source_name = { copilot = "Copilot" },
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -51,13 +51,7 @@ return {
|
||||||
sources = {
|
sources = {
|
||||||
compat = { "supermaven" },
|
compat = { "supermaven" },
|
||||||
},
|
},
|
||||||
completion = {
|
providers = { supermaven = { kind = "Supermaven" } },
|
||||||
menu = {
|
|
||||||
draw = {
|
|
||||||
override_kind_by_source_name = { supermaven = "Supermaven" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
} or nil,
|
} or nil,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,13 +42,7 @@ return {
|
||||||
sources = {
|
sources = {
|
||||||
compat = { "cmp_tabnine" },
|
compat = { "cmp_tabnine" },
|
||||||
},
|
},
|
||||||
completion = {
|
providers = { cmp_tabnine = { kind = "TabNine" } },
|
||||||
menu = {
|
|
||||||
draw = {
|
|
||||||
override_kind_by_source_name = { cmp_tabnine = "TabNine" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ return {
|
||||||
completion = {
|
completion = {
|
||||||
menu = {
|
menu = {
|
||||||
draw = {
|
draw = {
|
||||||
override_kind_by_source_name = {},
|
|
||||||
treesitter = true,
|
treesitter = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -96,22 +95,22 @@ return {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local override_kind_by_source_name = opts.completion.menu.draw.override_kind_by_source_name or {}
|
-- check if we need to override symbol kinds
|
||||||
local kind = {
|
for _, provider in pairs(opts.sources.providers or {}) do
|
||||||
text = function(ctx)
|
---@cast provider blink.cmp.SourceProviderConfig|{kind?:string}
|
||||||
local kind_override = override_kind_by_source_name[ctx.source_name]
|
if provider.kind then
|
||||||
return kind_override and kind_override or ctx.kind
|
require("blink.cmp.types").CompletionItemKind[provider.kind] = provider.kind
|
||||||
end,
|
---@param ctx blink.cmp.Context
|
||||||
highlight = function(ctx)
|
---@param items blink.cmp.CompletionItem[]
|
||||||
local kind_override = override_kind_by_source_name[ctx.source_name]
|
provider.transform_items = function(ctx, items)
|
||||||
return kind_override and "BlinkCmpKind" .. kind_override
|
for _, item in ipairs(items) do
|
||||||
or require("blink.cmp.completion.windows.render.tailwind").get_hl(ctx)
|
item.kind = provider.kind or item.kind
|
||||||
or ("BlinkCmpKind" .. ctx.kind)
|
end
|
||||||
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)
|
require("blink.cmp").setup(opts)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue