liuchengxu / eleline.vim

:herb: Another elegant statusline for vim
MIT License
311 stars 79 forks source link

No git branch name #41

Closed rockyzhang24 closed 3 years ago

rockyzhang24 commented 3 years ago

Hello,

The branch name is not shown. I am not using vim-fugitive.

neovim version: v0.5.0-dev+4d1fc167a, i.e., the latest master (installed via brew --HEAD) eleline: I have already updated it to the lastest

I attached a screenshot showing the plugins I installed so far image

Based on the README, the branch should be shown via the job feature. I don't know what's wrong on my side. Could you please do me a favor.

Thank you very much.

liuchengxu commented 3 years ago

You should try to reproduce with a minimal vimrc.

rockyzhang24 commented 3 years ago

Still having no idea. 😭

rockyzhang24 commented 3 years ago

I reproduced with a very minimal vimrc. I was just using minpac plugin manager to install eleline. The branch name was still not shown. Then I did some further investigation. Please take a look at this piece of code in eleline.vim (https://github.com/liuchengxu/eleline.vim/blob/master/plugin/eleline.vim#L94)

  if !exists('*FugitiveExtractGitDir')
    return ''
  endif

I added echom "aaaa" right above the return '' and in neovim I could see the output aaaa, which means the running fell into this if block, and it returns an empty string eventually. I am not sure whether or not this is the reason leading to the issue.

UPDATE: I didn't install vim-fugitive because as the README said it is not required if I am using the latest neovim, right? However, based on the code itself, it seems that vim-fugitive is necessary. If vim supports the job feature, it will get the branch name asynchronously but vim-fugitive plugin should be installed no matter what, right?

Thank you very much.

liuchengxu commented 3 years ago

Ok, the README is not very clear, eleline.vim will use the job feature to retrieve the git branch info when in a git repo, but the detection of the git directory is still dependent on the API of vim-fugitive.

rockyzhang24 commented 3 years ago

Okay, so vim-fugitive is definitely required. I think it'd better update the README to make it clearer.

Thank you for your help.

liuchengxu commented 3 years ago

Feel free to send a PR for adding such a note.