fix(extras.ai): blink.cmp integration and menu drawing

This commit is contained in:
Stefan Boca 2024-12-02 16:33:30 -08:00
parent 4a626a8137
commit c6ae68259f
No known key found for this signature in database
4 changed files with 70 additions and 37 deletions

View file

@ -55,17 +55,32 @@ return {
end,
},
{
vim.g.ai_cmp and {
"saghen/blink.cmp",
optional = true,
dependencies = { "codeium.nvim", "saghen/blink.compat" },
opts = {
sources = {
compat = vim.g.ai_cmp and { "codeium" } or nil,
compat = { "codeium" },
},
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,
},
},
},
},
},
},
dependencies = {
"codeium.nvim",
vim.g.ai_cmp and "saghen/blink.compat" or nil,
},
},
} or nil,
}

View file

@ -94,31 +94,37 @@ return {
},
},
-- blink.cmp
{
vim.g.ai_cmp and {
"saghen/blink.cmp",
optional = true,
dependencies = {
{
"giuxtaposition/blink-cmp-copilot",
enabled = vim.g.ai_cmp, -- only enable if needed
specs = {
{
"blink.cmp",
optional = true,
opts = {
sources = {
providers = {
copilot = { name = "copilot", module = "blink-cmp-copilot" },
},
completion = {
enabled_providers = { "copilot" },
},
dependencies = { "giuxtaposition/blink-cmp-copilot" },
opts = {
sources = {
completion = {
enabled_providers = { "copilot" },
},
providers = {
copilot = { name = "copilot", module = "blink-cmp-copilot" },
},
},
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,
},
},
},
},
},
},
},
} or nil,
}

View file

@ -43,22 +43,34 @@ return {
end,
},
-- blink.cmp integration
{
vim.g.ai_cmp and {
"saghen/blink.cmp",
optional = true,
---@module 'blink.cmp'
---@type blink.cmp.Config
dependencies = { "supermaven-nvim", "saghen/blink.compat" },
opts = {
sources = {
compat = vim.g.ai_cmp and { "supermaven" } or nil,
compat = { "supermaven" },
},
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,
},
},
},
},
},
},
dependencies = {
"supermaven-nvim",
vim.g.ai_cmp and "saghen/blink.compat" or nil,
},
},
} or nil,
{
"nvim-lualine/lualine.nvim",

View file

@ -52,7 +52,7 @@ return {
auto_show_delay_ms = 200,
},
ghost_text = {
enabled = vim.g.ai_cmp,
enabled = true,
},
},