Skip to content

fix(mcphub-nvim): disable make_vars to prevent codecompanion load order error - #1787

Closed
syltharion wants to merge 1 commit into
AstroNvim:mainfrom
syltharion:fix/mcphub-codecompanion-make-vars
Closed

syltharion wants to merge 1 commit into
AstroNvim:mainfrom
syltharion:fix/mcphub-codecompanion-make-vars

Conversation

@syltharion

Copy link
Copy Markdown
Contributor

Summary

Sets make_vars = false in the mcphub codecompanion extension config to prevent a load order crash.

Problem

When mcphub loads before codecompanion is fully initialized, the make_vars = true option triggers variable registration in a vim.schedule callback. At that point, codecompanion's variable registry table is still nil, causing:

bad argument #1 to 'pairs' (table expected, got nil)
mcphub/extensions/codecompanion/variables.lua:20

Fix

Disable make_vars by default. This prevents the crash while keeping make_slash_commands and show_result_in_chat enabled. Users who need MCP variables in codecompanion can re-enable this in their own config after ensuring proper load order.

Closes #1777

…er error

Closes AstroNvim#1777

When mcphub loads before codecompanion is fully initialized, the
make_vars option triggers variable registration that fails with
'bad argument AstroNvim#1 to pairs (table expected, got nil)' because
codecompanion's variable registry is not yet available.

Disable make_vars by default to prevent the crash. Users who need
MCP variables in codecompanion can re-enable this after ensuring
mcphub loads after codecompanion.
@github-actions

Copy link
Copy Markdown

Review Checklist

Does this PR follow the [Contribution Guidelines](development guidelines)? Following is a partial checklist:

Proper conventional commit scoping:

  • If you are adding a new plugin, the scope would be the name of the category it is being added into. ex. feat(utility): added noice.nvim plugin

  • If you are modifying a pre-existing plugin or pack, the scope would be the name of the plugin folder. ex. fix(noice-nvim): fix LSP handler error

  • Pull request title has the appropriate conventional commit type and scope where the scope is the name of the pre-existing directory in the project as described above

  • README is properly formatted and uses fenced in links with <url> unless they are inside a [title](url)

  • Entry returns a single plugin spec with the new plugin as the only top level spec (not applicable for recipes or packs).

  • Proper usage of opts table rather than setting things up with the config function.

  • Proper usage of specs table for all specs that are not dependencies of a given plugin (not applicable for recipes or packs).

@syltharion syltharion closed this Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant