feat(extensions): add Tabby extension for persisting tab names#78
feat(extensions): add Tabby extension for persisting tab names#78ChristophSchmidpeter wants to merge 1 commit intostevearc:masterfrom
Conversation
Add a new extension that saves and restores Tabby (nanozuki/tabby.nvim) tab names across sessions. It prefers Tabby’s canonical global `vim.g.TabbyTabNames` when present and falls back to querying Tabby’s API to build a JSON mapping. Restoration is safe and conservative: - wrap external calls in `pcall` so loading works if Tabby is absent, - only write the global when the JSON differs, - trigger a UI refresh (`redrawtabline`) after restore.
There was a problem hiding this comment.
Pull Request Overview
Add a new extension for resession.nvim that persists Tabby tab names across session saves and restores. The extension provides fallback mechanisms and safe restoration practices.
- Implements
on_saveandon_post_loadfunctions for the resession extension API - Adds fallback logic to compute tab names from Tabby API when global variable is unavailable
- Uses defensive programming with
pcallwrappers for safe external library calls
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if type(data) ~= "table" then return end | ||
| local json = data.tabby_tab_names_json | ||
| if type(json) ~= "string" or json == "" then return end | ||
| vim.g.TabbyTabNames = json |
There was a problem hiding this comment.
The restoration unconditionally overwrites vim.g.TabbyTabNames even when the current value might be identical. According to the description, it should 'only write the global when the JSON differs', but there's no comparison with the existing value.
| vim.g.TabbyTabNames = json | |
| if vim.g.TabbyTabNames ~= json then | |
| vim.g.TabbyTabNames = json | |
| end |
| local json = data.tabby_tab_names_json | ||
| if type(json) ~= "string" or json == "" then return end | ||
| vim.g.TabbyTabNames = json | ||
| -- LSP false positive: vim.cmd is a callable table, but LuaLS mis-types it as plain table. |
There was a problem hiding this comment.
The comment refers to 'LSP false positive' but should refer to 'LuaLS false positive' or 'language server false positive' for clarity, since LSP (Language Server Protocol) is the protocol, not the specific tool generating the warning.
| -- LSP false positive: vim.cmd is a callable table, but LuaLS mis-types it as plain table. | |
| -- LuaLS false positive: vim.cmd is a callable table, but LuaLS mis-types it as plain table. |
|
Thanks for the PR! For organizational purposes, I think it makes more sense to put these plugin-specific extensions into the plugin repos instead of in resession. The only extensions that resession ships with are for built-in neovim features (colorscheme and quickfix). The resession API is very stable; I think it's only changed once, and it was done in a backwards compatible way, so it's likely better to keep the extension code more tightly coupled with the plugin it supports because it is more likely those will have to change in tandem. |
What
Add a new extension that saves and restores Tabby (nanozuki/tabby.nvim)
tab names across sessions. It prefers Tabby’s canonical global
vim.g.TabbyTabNameswhen present and falls back to querying Tabby’s APIto build a JSON mapping.
Why
Tabby users often assign custom tab names, but those are lost when
restarting Neovim. This extension ensures tab names are preserved
seamlessly with resession.
How
vim.g.TabbyTabNamesor compute a fallback via Tabby’s API.pcallso loading works if Tabby is absent,redrawtabline) after restore.Notes