mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
feat(extras.ai): blink.cmp source kind overrides
allows multiple ai extras to be enabled at once, and drawn correctly
This commit is contained in:
parent
55b7d01e44
commit
069fe153ee
5 changed files with 25 additions and 49 deletions
|
|
@ -66,18 +66,7 @@ return {
|
|||
completion = {
|
||||
menu = {
|
||||
draw = {
|
||||
components = {
|
||||
kind = {
|
||||
text = function(ctx)
|
||||
return ctx.source_name == "codeium" and "Codeium" or ctx.kind
|
||||
end,
|
||||
highlight = function(ctx)
|
||||
return ctx.source_name == "codeium" and "BlinkCmpKindCodeium"
|
||||
or require("blink.cmp.completion.windows.render.tailwind").get_hl(ctx)
|
||||
or ("BlinkCmpKind" .. ctx.kind)
|
||||
end,
|
||||
},
|
||||
},
|
||||
override_kind_by_source_name = { codeium = "Codeium" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -110,18 +110,7 @@ return {
|
|||
completion = {
|
||||
menu = {
|
||||
draw = {
|
||||
components = {
|
||||
kind = {
|
||||
text = function(ctx)
|
||||
return ctx.source_name == "copilot" and "Copilot" or ctx.kind
|
||||
end,
|
||||
highlight = function(ctx)
|
||||
return ctx.source_name == "copilot" and "BlinkCmpKindCopilot"
|
||||
or require("blink.cmp.completion.windows.render.tailwind").get_hl(ctx)
|
||||
or ("BlinkCmpKind" .. ctx.kind)
|
||||
end,
|
||||
},
|
||||
},
|
||||
override_kind_by_source_name = { copilot = "Copilot" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -54,18 +54,7 @@ return {
|
|||
completion = {
|
||||
menu = {
|
||||
draw = {
|
||||
components = {
|
||||
kind = {
|
||||
text = function(ctx)
|
||||
return ctx.source_name == "supermaven" and "Supermaven" or ctx.kind
|
||||
end,
|
||||
highlight = function(ctx)
|
||||
return ctx.source_name == "supermaven" and "BlinkCmpKindSupermaven"
|
||||
or require("blink.cmp.completion.windows.render.tailwind").get_hl(ctx)
|
||||
or ("BlinkCmpKind" .. ctx.kind)
|
||||
end,
|
||||
},
|
||||
},
|
||||
override_kind_by_source_name = { supermaven = "Supermaven" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -45,18 +45,7 @@ return {
|
|||
completion = {
|
||||
menu = {
|
||||
draw = {
|
||||
components = {
|
||||
kind = {
|
||||
text = function(ctx)
|
||||
return ctx.source_name == "cmp_tabnine" and "TabNine" or ctx.kind
|
||||
end,
|
||||
highlight = function(ctx)
|
||||
return ctx.source_name == "cmp_tabnine" and "BlinkCmpKindTabNine"
|
||||
or require("blink.cmp.completion.windows.render.tailwind").get_hl(ctx)
|
||||
or ("BlinkCmpKind" .. ctx.kind)
|
||||
end,
|
||||
},
|
||||
},
|
||||
override_kind_by_source_name = { cmp_tabnine = "TabNine" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -45,7 +45,10 @@ return {
|
|||
completion = {
|
||||
menu = {
|
||||
winblend = vim.o.pumblend,
|
||||
draw = { treesitter = true },
|
||||
draw = {
|
||||
override_kind_by_source_name = {},
|
||||
treesitter = true,
|
||||
},
|
||||
},
|
||||
documentation = {
|
||||
auto_show = true,
|
||||
|
|
@ -93,6 +96,23 @@ return {
|
|||
table.insert(enabled, source)
|
||||
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,
|
||||
}
|
||||
|
||||
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