Skip to content

mcphub-nvim: make_vars causes error in codecompanion due to load order #1777

Description

@nPaul

Checklist

  • I have searched through the AstroNvim documentation
  • I have searched through the existing issues of this project
  • I have searched the existing issues of plugins related to this issue
  • I can replicate the bug with the minimal repro.lua provided below

Neovim version (nvim -v)

NVIM v0.12.2

Operating system/version

Linux

Terminal/GUI

bash

Describe the bug

When using the mcphub.nvim plugin from astrocommunity together with codecompanion.nvim, a "bad argument #1 to 'pairs' (table expected, got nil)" error occurs when starting Neovim. The error occurs when the mcphub extension attempts to register variables (make_vars = true) with codecompanion.

Steps to Reproduce

  1. Install the mcphub.nvim and codecompanion.nvim plugins via astrocommunity.
  2. Restart NeoVim
  3. open any file
  4. see error in bottom panel

Expected behavior

vim.schedule callback: ...b.nvim/lua/mcphub/extensions/codecompanion/variables.lua:20: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
[C]: in function 'pairs'
...b.nvim/lua/mcphub/extensions/codecompanion/variables.lua:20: in function 'register'
...b.nvim/lua/mcphub/extensions/codecompanion/variables.lua:92: in function ''
vim/_core/editor.lua: in function <vim/_core/editor.lua:0>

Screenshots

No response

Additional Context

No response

Minimal configuration

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  -- stylua: ignore
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)

-- install plugins
local plugins = {
  { "AstroNvim/AstroNvim", import = "astronvim.plugins" },
  { "AstroNvim/astrocommunity" },

  -- add any other plugins/customizations here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

-- add anything else here (autocommands, vim.filetype, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions