feat(extras.ai): blink.cmp integration and kind overrides for menu drawing (#4942)
## Description blink.cmp integration for codeium and copilot, and correct menu drawing for codeium, copilot, and supermaven. I've simplified the blink.cmp config a bit for these extras (especially for copilot, which was extremely nested) by only including the blink.cmp spec if vim.g.ai_cmp is true. Multiple AI extras can now be enabled at the same time with blink.cmp. blink.cmp ghost text is now always enabled. Although some ai plugins always display virtual text, at worst it overlaps with blink's ghost text and is not noticable. Lastly, I can't test copilot because I don't have a subscription, nor do I want to sign up for one, but it should work just as well as the others. ## Screenshots With Codeium:  Multiple extras enabled at the same time:  ## Checklist - [X] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --------- Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
@ -44,8 +44,9 @@ return {
|
||||
nerd_font_variant = "mono",
|
||||
completion = {
|
||||
menu = {
|
||||
winblend = vim.o.pumblend,
|
||||
draw = { treesitter = true },
|
||||
draw = {
|
||||
treesitter = true,
|
||||
},
|
||||
},
|
||||
documentation = {
|
||||
auto_show = true,
|
||||
@ -93,6 +94,26 @@ return {
|
||||
table.insert(enabled, source)
|
||||
end
|
||||
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
|
||||
---@type fun(ctx: blink.cmp.Context, items: blink.cmp.CompletionItem[]): blink.cmp.CompletionItem[]
|
||||
local transform_items = provider.transform_items
|
||||
---@param ctx blink.cmp.Context
|
||||
---@param items blink.cmp.CompletionItem[]
|
||||
provider.transform_items = function(ctx, items)
|
||||
items = transform_items and transform_items(ctx, items) or items
|
||||
for _, item in ipairs(items) do
|
||||
item.kind = provider.kind or item.kind
|
||||
end
|
||||
return items
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require("blink.cmp").setup(opts)
|
||||
end,
|
||||
},
|
||||
|
Reference in New Issue
Block a user