I am using lightline.vim and I would like to show the current git branch. At the moment, I am doing so using vim-fugitive, however, I do not use this plugin at all, except for showing the git branch in the status line.
My question is:
Is there a way to show the git branch in the status line without using fugitive?
I tried to create a custom function that I hooked to lightline. The function fetched the current git branch using the system
vimscript function. It (didn't) work well, except that the status line was refreshed on every keystroke, which broke everything else and made vim unusable. Essentially, the git branch was being fetched using the system
function on every keystroke...
So that's not a viable solution. What I "could" do, is create a global variable which says whether or not the git branch was fetched, and prevent the custom function from fetching the branch name again if it was already fetched. Then I could fetch the branch name again every time MacVim loses focus (not sure how to do that using terminal vim). That is not ideal though...
Any ideas on how to solve this problem please?