Unlocking the mysteries of the vim function for the uninitiated ...
8i8 opened this issue · 8 comments
Hello itchyny,
Thank you for your time and your advice.
Would you be so kind as to give a brief explanation of how to implement the function in your vim gitbranch plugin, I am relatively new to the programming world, also due to my current use of the vundle plugin to install vim scripts I am consequently lacking in experience in this area.
How can I call this function, is is possible to make the git branch name appear in lightline?
Thank you for your kind consideration and should you see fit; Any consequent advice.
Firstly, try :echo gitbranch#name() . To configure this plugin to appear in the statusline with lightline, register gitbranch#name to g:lightline.component_function.
So I will add :echo gitbranch#name() to my vimrc, right?
Where do I register gitbranch#name# I have never written a vim script.
Thank you.
- Open a file in a git repository.
- Execute
:echo gitbranch#name() - The command shows the name of the current branch.
Ah great, yes it does, I feel silly not to have tried that!
So, can I add this function to the light line script that you have also written?
Add the following configuration to your .vimrc file.
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'gitbranch#name',
\ }
\ }And then restart Vim.
Thank you so much itchyny; It works perfectly.
I am very greatfull for both your code and your help in getting it installed.
Fine. Good luck!