You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(lualine): add global variables API for lazy-loading support
- Add vim.g.mcphub_status, vim.g.mcphub_servers_count, vim.g.mcphub_executing
- Move state tracking logic from lualine extension to hub core
- Update documentation with recommended global variables approach
- Deprecate full lualine component with warning
- Support spinners during hub startup/restart and execution
- Show '-' when hub is stopped or not loaded
Fixes#208
Copy file name to clipboardExpand all lines: doc/extensions/lualine.md
+68-7Lines changed: 68 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,82 @@
1
1
# Lualine Integration
2
2
3
-
MCP Hub provides a lualine component that can be used to show the status of the MCP Hub and the number of connected servers. Add the component to a lualine section to use it. The following example shows how to add the component to the `lualine_x` section:
3
+
MCP Hub provides multiple ways to integrate with lualine, with the recommended approach using global variables for optimal lazy-loading support.
4
+
5
+
## Recommended: Global Variables Approach
6
+
7
+
Use MCPHub's global variables for a lightweight, lazy-load friendly component:
elseifstatus=="starting" orstatus=="restarting" then
47
+
return { fg="#ffb86c" } -- Orange for connecting
48
+
else
49
+
return { fg="#ff5555" } -- Red for error/stopped
50
+
end
51
+
end,
52
+
},
11
53
},
12
54
},
13
55
}
14
56
```
15
57
58
+
### Available Global Variables
59
+
60
+
MCPHub automatically maintains these global variables:
61
+
-`vim.g.loaded_mcphub` - Whether MCPHub plugin is loaded (set by plugin loader)
62
+
-`vim.g.mcphub_status` - Current hub state ("starting", "ready", "stopped", etc.)
63
+
-`vim.g.mcphub_servers_count` - Number of connected servers
64
+
-`vim.g.mcphub_executing` - Whether a tool/resource is currently executing
65
+
66
+
67
+
## Legacy: Full Component (Loads MCPHub) - DEPRECATED
68
+
69
+
**⚠️ DEPRECATED**: This approach will load MCPHub even with lazy loading enabled and shows a deprecation warning. Use the global variables approach above instead.
Copy file name to clipboardExpand all lines: lua/mcphub/extensions/lualine.lua
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,11 @@
1
1
--[[
2
2
--NOTE: Having cmd = "MCPHub" or lazy = true in user's lazy config, and adding lualine component using require("mcphub.extensions.lualine") will start the hub indirectly.
3
3
--]]
4
+
5
+
-- DEPRECATED: This lualine component will load MCPHub even with lazy loading.
6
+
-- Use the global variables approach instead: vim.g.mcphub_status, vim.g.mcphub_servers_count, vim.g.mcphub_executing
7
+
-- See documentation for recommended usage: doc/extensions/lualine.md
0 commit comments