fix(nvim): ensure codecompanion config structure exists before mcphub extension loads

This commit is contained in:
2025-12-24 14:43:29 +01:00
parent fdb4df09be
commit cebca892b8

View File

@@ -1,17 +1,22 @@
require("codecompanion").setup({
ignore_warnings = true,
extensions = {
mcphub = {
callback = "mcphub.extensions.codecompanion",
opts = {
make_vars = true,
make_slash_commands = true,
show_result_in_chat = true,
},
},
},
strategies = {
chat = { adapter = "openai" },
inline = { adapter = "openai" },
},
})
-- Load mcphub extension after codecompanion is initialized
-- and ensure the config structure exists
local ok, cc_config = pcall(require, "codecompanion.config")
if ok then
cc_config.interactions = cc_config.interactions or {}
cc_config.interactions.chat = cc_config.interactions.chat or {}
cc_config.interactions.chat.tools = cc_config.interactions.chat.tools or {}
require("mcphub.extensions.codecompanion").setup({
make_vars = true,
make_slash_commands = true,
show_result_in_chat = true,
})
end