AstroNvim / AstroNvim/astrocommunity
mcphub-nvim: make_vars causes error in codecompanion due to load order
- Dominant language
- Lua
- Stars
- 1.7k
- Forks
- 313
- PR merge metrics
- No merged PRs in 30d
Description
### Checklist
- [x] I have searched through the AstroNvim documentation
- [x] I have searched through the existing issues of this project
- [x] I have searched the existing issues of plugins related to this issue
- [x] 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
### Screenshots
_No response_
### Additional Context
_No response_
### Minimal configuration
```Lua
-- 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.)
```
Contributor guide
Research direction
Run the provided repro.lua with nvim -u repro.lua, then inspect mcphub/extensions/codecompanion/variables.lua at the register function around lines 20 and 92. Trace the startup load order and the values passed to registration. Done means the minimal configuration starts without the pairs error when mcphub.nvim and codecompanion.nvim load together.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100