tpope / vim-fugitive

fugitive.vim: A Git wrapper so awesome, it should be illegal
https://www.vim.org/scripts/script.php?script_id=2975
20.08k stars 1.01k forks source link

Can we bring the `fugitive_autoreload_status` setting back? #2207

Open brookhong opened 1 year ago

brookhong commented 1 year ago

In some large repo, it takes minutes to run git status. Vim freezes frequently if Git window is open.

Is it possible to turn off autoreload_status and let user to refresh status on demand?

This is some related setting https://github.com/tpope/vim-fugitive/blob/5d99841b22928f1597d447c68de844989bf9a804/autoload/fugitive.vim#L2062.

tpope commented 1 year ago

There's now two kinds of reloading: eager and lazy. Eager immediately reloads any visible Fugitive windows, and is used when you explicitly invoke a Fugitive command that will likely change the status, like :Git add or :Gwrite. Lazy waits to reload until the Fugitive window is in focus, and is used for other things that could potentially change the status, like saving a file or :!.

So it's no longer as simple as a Boolean option, that's why the old option went away. My proposal would be to add an option that makes all reloads lazy. I think if the Fugitive window is in focus, then we should still reload it, otherwise some operations won't work right. Does an option for that sound like it would solve or at least substantially mitigate your problem?

brookhong commented 1 year ago

Thanks for looking into this.

So if the proposed option is on, it will not reload status after we invoke a Fugitive command unless the Git window is focus?

If yes, that should work as we could mitigate the issue by avoiding switching to the Git window. Additionally it would be better to make the option could be set for a specific repository, since Git status runs fast for most repositories.

tpope commented 9 months ago

Have you tried git config core.untrackedCache true and/or git config core.fsmonitor true, to see if those improve performance to an acceptable level?

I started working on bring the option back, but then quickly decided I'd rather spend what time I have working on making it async instead. This turned out to be a major project.

brookhong commented 9 months ago

Those git settings haven't made things better for me.

I might haven't described the issue very well. It is acceptable to reload status when a Fugitive command is invoked with Git window open, the worse part is that it is to reload status when none Fugitive command is invoked, such as switching back to vim/nvim from another app(observed in NVIM v0.9.5 under Mac).

tpope commented 9 months ago

There is an option to turn off reloads on focusing Vim:

let g:fugitive_focus_gained = v:false