fix(copliot): restructure copilot-cmp spec

This commit is contained in:
Folke Lemaitre 2024-12-12 13:32:56 +01:00
parent bdc865b291
commit 34d2bdcac6

View file

@ -58,57 +58,59 @@ return {
end, end,
}, },
-- copilot cmp source vim.g.ai_cmp
{ and {
"nvim-cmp", -- copilot cmp source
optional = true, {
dependencies = { -- this will only be evaluated if nvim-cmp is enabled "nvim-cmp",
{ optional = true,
"zbirenbaum/copilot-cmp", dependencies = { -- this will only be evaluated if nvim-cmp is enabled
enabled = vim.g.ai_cmp, -- only enable if wanted {
opts = {}, "zbirenbaum/copilot-cmp",
config = function(_, opts) opts = {},
local copilot_cmp = require("copilot_cmp") config = function(_, opts)
copilot_cmp.setup(opts) local copilot_cmp = require("copilot_cmp")
-- attach cmp source whenever copilot attaches copilot_cmp.setup(opts)
-- fixes lazy-loading issues with the copilot cmp source -- attach cmp source whenever copilot attaches
LazyVim.lsp.on_attach(function() -- fixes lazy-loading issues with the copilot cmp source
copilot_cmp._on_insert_enter({}) LazyVim.lsp.on_attach(function()
end, "copilot") copilot_cmp._on_insert_enter({})
end, end, "copilot")
specs = { end,
{ specs = {
"nvim-cmp", {
optional = true, "nvim-cmp",
---@param opts cmp.ConfigSchema optional = true,
opts = function(_, opts) ---@param opts cmp.ConfigSchema
table.insert(opts.sources, 1, { opts = function(_, opts)
name = "copilot", table.insert(opts.sources, 1, {
group_index = 1, name = "copilot",
priority = 100, group_index = 1,
}) priority = 100,
end, })
end,
},
},
},
}, },
}, },
}, {
}, "saghen/blink.cmp",
}, optional = true,
dependencies = { "giuxtaposition/blink-cmp-copilot" },
vim.g.ai_cmp and { opts = {
"saghen/blink.cmp", sources = {
optional = true, default = { "copilot" },
dependencies = { "giuxtaposition/blink-cmp-copilot" }, providers = {
opts = { copilot = {
sources = { name = "copilot",
default = { "copilot" }, module = "blink-cmp-copilot",
providers = { kind = "Copilot",
copilot = { },
name = "copilot", },
module = "blink-cmp-copilot", },
kind = "Copilot",
}, },
}, },
}, }
}, or nil,
} or nil,
} }