Closed Frederick888 closed 3 years ago
This is the least favorite option as it's not async and can make your vim really slow, see https://github.com/liuchengxu/eleline.vim/blob/200a6fbe66027c331029de941797fd000ff518aa/plugin/eleline.vim#L127-L130
With this patch, you won't be benefited from the async git branch detector.
@liuchengxu Ah sorry, somehow I didn't see that line. I'll close this PR.
Out of curiosity, is it possible to trigger ElelineGitBranch(1)
after :G checkout
? Not unless vim-fugitive implements some sort of customisable callback?
Wrap :G checkout
and call ElelineGitBranch(1)
into a single function/command?
@liuchengxu Hmm... It seems that tpope's been trying to improve fugitive's command/mapping consistency, e.g. removing Gpush
Gpull
etc in favour of :G
, so having a custom wrapper command appears to be somewhat going back in this regard.
What about using g:coc_git_status
(not b:
) for git branch? Just realised coc-git provides this.
Well, I'm not against adding another git branch provider as long as it's fast enough, and I think coc-git is also good for this task.
Hmm... It seems coc-git only refreshes on text change, so still right after a checkout g:coc_git_status
is outdated.
I'll do some research to see if there are better options.
@liuchengxu
So fugitive itself now is async [1] and it in the end calls fugitive#ReloadStatus
[2] and then s:DoAutocmdChanged
, what about:
autocmd User FugitiveChanged call ElelineGitBranch(1)
" or
autocmd User FugitiveChanged if exists("b:eleline_branch") | unlet b:eleline_branch | endif
[1] https://github.com/tpope/vim-fugitive/blob/41960996e0c532069533072b3fd820fafe9ce0b3/autoload/fugitive.vim#L2970-L2990 [2] https://github.com/tpope/vim-fugitive/blob/41960996e0c532069533072b3fd820fafe9ce0b3/autoload/fugitive.vim#L3358-L3373
So fugitive itself now is async
Not for fugitive#head()
.
I'm not against adding a fugitive autocmd if that helps.
Thanks, @liuchengxu. And btw tpope has suggested using this autocmd in some scenarios, e.g. tpope/vim-fugitive#503, tpope/vim-fugitive#1586. Do you think it's worth being mentioned in this project's readme?
I don't have a strong opinion, but it's not bad to have them anyway.
This solves the branch name out-of-sync issue after :G checkout.