Skip to content

feat(#3394): experimental async first git load - #3395

Open
tomo-2525 wants to merge 2 commits into
nvim-tree:masterfrom
tomo-2525:feat/git-async-load
Open

tomo-2525 wants to merge 2 commits into
nvim-tree:masterfrom
tomo-2525:feat/git-async-load

Conversation

@tomo-2525

Copy link
Copy Markdown

resolves #3394

Design

Opening a large repository of my notes was slow, so I wanted the git status to be loaded lazily.

  • This is an experimental option, experimental.git_async_load, off by default.
  • The tree is still built synchronously (Explorer:_load is unchanged), and only the git status is loaded later. This keeps the change small and inside lua/nvim-tree/git/init.lua.
  • While the git status is loading, no git status is shown, git_ignored files are shown and git_clean hides every file. I think a short time without git status is better than Nvim blocking.

AI usage

AI used: Claude (Claude Opus 5.5) in Claude Code. The code was also reviewed by another Claude model (Claude Fable 5.2).

All code and documentation in this PR were written by Claude. None was written by me.

What I did:

  • noticed the slow startup and asked Claude to investigate the cause
  • decided on the asynchronous approach, and to raise the issue and this PR
  • chose the design decisions: an experimental option, keeping the code in git/init.lua, and following git.timeout
  • asked Claude for a second review; Claude had Claude Fable review the code and fixed the bug it found

Testing

Claude ran these tests and I reviewed the results.

  • Time until opening the tree returns, in a repository with about 27,000 tracked files and 12,600 directories: 1.6 - 1.9s with the option off, 0.05 - 0.2s with it on.
  • After the git status has loaded, the tree lines, git highlights and cursor line were compared with the option off and on, in 16 combinations: a small test repository and the large repository, git_ignored and git_clean on and off, and opening at the root, expanding after loading, or opening a file with find_file. 14 were identical. The other 2 are the known difference documented in the option: with git_clean, find_file cannot find the file while the status is loading.
  • The bug found in the review was reproduced: a directory opened and closed while loading kept the old children. The option off and on are identical after the fix.
  • make lint, make check, make style, make style-doc, make format-check and make help-update pass.

I also tried it with my own configuration in the large repository, and opening it is clearly faster.

tomo-2525 and others added 2 commits November 22, 2026 15:01
…nc git load

Closed directories explored while git status was in flight kept the
children filtered against the empty status, and reopening them does not
explore them again. Walk every explored directory instead of the open
ones only.

Document that git.timeout still applies and that reloads still block,
and add line comments to the changed functions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 06:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved Git-refresh issues can leave hidden directories stale, overwrite grouped submodule statuses and filters, and allow older initial-scan results to replace newer updates.

3 open issues
What changed in this PR

Adds an opt-in asynchronous initial Git status load to reduce blocking when opening large repositories, addressing #3394 while keeping tree construction synchronous.

Changes:

  • Adds experimental.git_async_load, disabled by default.
  • Loads initial Git status in the background, then refreshes explored directories and restores cursor focus.
  • Documents temporary filter behavior, timeout handling, and synchronous reloads.
File Description
lua/​nvim-tree/​git/​init.lua Implements asynchronous initial loading, completion refreshes, and shared watcher creation.
lua/​nvim-tree/​config.lua Adds the disabled-by-default experimental option.
lua/​nvim-tree/​_meta/​config/​experimental.lua Defines and documents the option and its limitations.
doc/​nvim-tree-lua.txt Updates help text and the default configuration example.

Review effort: Balanced

Comment thread lua/nvim-tree/git/init.lua Resolved
Comment thread lua/nvim-tree/git/init.lua Resolved
Comment thread lua/nvim-tree/git/init.lua Resolved
@tomo-2525

Copy link
Copy Markdown
Author

The Copilot review on this PR was requested automatically by my GitHub settings. I did not intend it.
I tried to remove it but could not.
I have turned the setting off, so it will not happen again.

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.

Experimental: load the git status of a project asynchronously on first display

2 participants