Git status not updating after :G commit with fugitive #322
-
Hey, thank you so much for writing this plugin. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
I have the same problem. |
Beta Was this translation helpful? Give feedback.
-
The bad news is that there is not normally any way detect a git change that does not modify files on the file system. I tried adding a watcher on the git index but the git index but git is complicated... The good news is that Fugitive actually fires a custom user event anytime it does anything that might change git status, further establishing why tpope is a God amongst plugin developers (thanks tpope!). You can hook into that event and automatically refresh Neotree like this: vim.cmd[[
augroup FugitiveRefreshNeotree
autocmd!
autocmd User FugitiveChanged lua require("neo-tree.sources.manager").refresh("filesystem")
augroup END
]] There is of course a pure lua equivalent now in 0.7, but I haven't started using them yet. I'll look into whether I can detect the presence of Fugitive and subscribe to this event automatically if Fugitive is installed. |
Beta Was this translation helpful? Give feedback.
-
I actually just built this into Neo-tree, it is in |
Beta Was this translation helpful? Give feedback.
-
How about a periodic refresh? I switched from Fugutive to lazygit in a scratch terminal (it's ok i guess). From my side, I'll look into refreshing neo-tree imperatively when that scratch terminal closes, shouldn't be too hard. But, this morning I noticed that a commit I made and pushed last night was still orange (marked as staged) in neo-tree's fs view. A once-every-5-minutes or once-every-hour refresh shouldn't be too heavy on resources, no? |
Beta Was this translation helpful? Give feedback.
I actually just built this into Neo-tree, it is in
main
right now and will go out on the next release. It will now refresh on any Fugitive command that fires theFugitiveChanged
event, which should be anything that can alter git status.