fix(blink): correct properties for config validation

`blink.cmp` had an [update](834163eebd)
that forces strict config validation. This PR adapts to these changes.

Closes #5016.
This commit is contained in:
Iordanis Petkakis 2024-12-12 22:39:07 +02:00
parent aad0edbf74
commit ce556fb8d1
6 changed files with 37 additions and 23 deletions

View file

@ -61,8 +61,14 @@ return {
dependencies = { "codeium.nvim", "saghen/blink.compat" },
opts = {
sources = {
compat = { "codeium" },
providers = { codeium = { kind = "Codeium" } },
default = { "codeium" },
providers = {
codeium = {
name = "codeium",
module = "blink.compat.source",
kind = "Codeium",
},
},
},
},
} or nil,

View file

@ -49,8 +49,14 @@ return {
dependencies = { "supermaven-nvim", "saghen/blink.compat" },
opts = {
sources = {
compat = { "supermaven" },
providers = { supermaven = { kind = "Supermaven" } },
default = { "supermaven" },
providers = {
supermaven = {
name = "supermaven",
module = "blink.compat.source",
kind = "Supermaven",
},
},
},
},
} or nil,

View file

@ -40,8 +40,14 @@ return {
dependencies = { "tzachar/cmp-tabnine", "saghen/blink.compat" },
opts = {
sources = {
compat = { "cmp_tabnine" },
providers = { cmp_tabnine = { kind = "TabNine" } },
default = { "cmp_tabnine" },
providers = {
cmp_tabnine = {
name = "cmp_tabnine",
module = "blink.compat.source",
kind = "TabNine",
},
},
},
},
},

View file

@ -12,7 +12,6 @@ return {
build = vim.g.lazyvim_blink_main and "cargo build --release",
opts_extend = {
"sources.completion.enabled_providers",
"sources.compat",
"sources.default",
},
dependencies = {
@ -64,9 +63,6 @@ return {
-- signature = { enabled = true },
sources = {
-- adding any nvim-cmp sources here will enable them
-- with blink.compat
compat = {},
default = { "lsp", "path", "snippets", "buffer" },
},
@ -80,18 +76,7 @@ return {
},
---@param opts blink.cmp.Config | { sources: { compat: string[] } }
config = function(_, opts)
-- setup compat sources
local enabled = opts.sources.default
for _, source in ipairs(opts.sources.compat or {}) do
opts.sources.providers[source] = vim.tbl_deep_extend(
"force",
{ name = source, module = "blink.compat.source" },
opts.sources.providers[source] or {}
)
if type(enabled) == "table" and not vim.tbl_contains(enabled, source) then
table.insert(enabled, source)
end
end
-- TODO: remove when blink made a new release > 0.7.6
if not vim.g.lazyvim_blink_main then

View file

@ -66,7 +66,15 @@ return {
{ "saadparwaiz1/cmp_luasnip" },
},
opts = {
sources = { compat = { "luasnip" } },
sources = {
default = { "luasnip" },
providers = {
luasnip = {
name = "luasnip",
module = "blink.compat.source",
},
},
},
snippets = {
expand = function(snippet)
require("luasnip").lsp_expand(snippet)

View file

@ -132,7 +132,10 @@ return {
sources = {
default = { "dadbod" },
providers = {
dadbod = { name = "Dadbod", module = "vim_dadbod_completion.blink" },
dadbod = {
name = "Dadbod",
module = "vim_dadbod_completion.blink",
},
},
},
},