Description
Project Board
Any and all contributions are most gratefully appreciated.
Please comment on or assign yourself an issue if you're working on it.
Current State
nvim-tree allows and supports exactly one window per tab, however there is some shared state between windows.
Problems
- Multiple windows may be opened in one tab via split, however this is not functional
- Windows across tabs are somewhat discrete in that they have their own buffer, however some state is shared e.g. opened folders and bleeds across tabs
Desired Outcome
- Discrete nvim-tree windows, with their own state that does not affect others.
- Single shared nvim-tree windows across tabs, with identical / mirrored state. This is similar to the tree of some IDEs.
Implementation Notes
- Single instance would use the one buffer and state. This would result in the tree being closed across tabs.
- Discrete instances would require the global state to be stored per-instance.
- Global states such as filesystem and git would need to be shared, with single global watchers / background tasks.
Limitations
- This will likely need to be a binary option. Providing a means to manage discrete and shared instances would be (impossibly?) problematic from a UX perspective.
- Floating tree windows are closed when they lose focus, including when swapping tabs. Floating would continue to be restricted to a single ephemeral instance.
Implementation Plan
An incremental approach is more practical, with a feature branch likely interrupting development due to its cross-cutting nature.
- Refactor: move global state / singletons under the explorer.
- Build, experimental feature flag: discrete tree instances for each window.
- Consolidate: callbacks or state updates such as git, watchers, refresh should be applied to each instance.
- Release 2.0.0: following experiment testing, release with the discrete option turned ON by default, as that is closest to current behaviour.
It's not clear yet whether 2 and 3 would be implemented at the same time or sequentially. Simplest/safest implementation can be determined once work begins on 2.
References
- Per Tab nvim-trees #457
- Allow opening the tree just like NERDTree in the current window or new splits when opening directories #1459
- setup switches tabs if nvim tree open in another tab #1491
:NvimTreeToggle
- toggle file explorer in all tabs #1493- tabnew should focus existing tab if file already opened #1687
- Keep tree open in all tabs #1880
- Reuse Buffer #1895
- NvimTree changes root in the other tab after it is reopened #1978
- Opening nvim-tree in a split breaks vinegar-style #2227
- Norton commander-like mode #2252
- Toggling folder expansion in one tab's tree affects the tree in another tab #2257
- how to use tcd instead of lcd/cd to maintain one context per tab #1847
- Is it possible to have separate nvim-tree in each tab with its own root etc? #1960
- How to get nvim-tree to use the same (single) instance in all tabs? #2244
- skip through empty directories #2497
- Retain Tree State on DirChanged #2488
- how to use one instance in different tab #2718
- Can't open a buffer in new tabpage when
quit_on_open
+hijack_unnamed_buffer_when_opening
are true #2851