Repository navigation
Description
Can this functionality be implemented utilising API?
No. The first git status of a project runs inside git.load_project, which is called from Explorer:_load
while the tree is built. No API can make that call asynchronous.
Is your feature request related to a problem? Please describe.
The first time nvim-tree shows a git repository, git.load_project runs git status synchronously,
and Nvim is blocked until it completes (GitRunner:wait).
nvim-tree runs git --no-optional-locks status --porcelain=v1 -z --ignored=matching -u.
In a large repository both -u (all untracked files) and --ignored walk every directory,
as the untracked cache cannot be used with them.
Measured on a repository with about 27,000 tracked files and 12,600 directories
(macOS, Nvim 0.12.5, git with fsmonitor and untracked cache enabled):
| git status options | time |
|---|---|
| none | 0.13s |
-uall only |
1.4s |
--ignored=matching only |
1.4 - 1.6s |
| both, as nvim-tree runs it | 1.4 - 1.7s |
When the tree is opened at startup beside a file (toggle({ focus = false, find_file = true })),
nothing is drawn until git status completes.
#1974 made the git watcher reloads asynchronous and noted that Explorer:_load has too great a fanout to be made async.
#3385 proposes making reload_explorer and reload_git asynchronous; it does not cover the first load.
Describe the solution you'd like
An experimental option, off by default, e.g. experimental.git_async_load.
It changes git.load_project only; Explorer:_load and explore stay synchronous:
- When the project is unknown, register an empty project and return it straight away, so the tree is drawn without git status.
The registered project also prevents anothergit statusfor the same project while the first one runs. - Run the same
git statuswith the asyncGitRunnercallback, asrefresh_dirdoes. - On completion, fill in the project, reload the explored directories of that project with
Explorer:reload
so that the git filters are applied, and keep the cursor on the same node.
With a prototype, opening the tree in the repository above takes 0.05 - 0.2s instead of 1.6 - 2.3s.
Once git status has completed, the rendered tree, git highlights and cursor line are identical to the synchronous load.
I compared them with git_ignored and git_clean on and off, with and without find_file.
Known differences while git status is running:
- no git status is shown,
git_ignoredfiles are shown andgit_cleanhides every file - with
git_clean,find_filecannot find the file at startup, so its directory is not opened
I will raise a PR with this prototype, referencing this issue.
Describe alternatives you've considered
git.disable_for_dirsfor large repositories: loses the git status in the tree.- A larger
git.timeout: prevents the git integration from being disabled, but the tree still blocks for the whole duration. - Opening the tree after
UIEnter: the file is drawn first, but Nvim still blocks for the same time afterwards.
Additional context
I used an AI assistant (Claude) to investigate the code and to draft the prototype and this issue.
I have reviewed the content and will answer questions myself.
Activity
fix(nvim-tree#3394): reload closed explored directories after the asy…
alex-courtis commentedon Nov 24, 2026
Testing Notes
Linux 7.3.5-arch1-1, ext4 on pcie5 disk
core.fsmonitorandcore.untrackedcachenot enabled as fsmonitor not available for linux.linux source repo:
This doesn't really prove anything, as the OS, filesystem and repo are different.
nvim-tree performance matches above ~70ms
Where to?
This is a change we should make.
It doesn't matter that I can't replicate performance issues, you can, and I can review the change regardless.
I've added millisecond log timings on the functional testing branch #3369 which could be picked to master if we need them.
I'll get to a review as time permits.