aboutsummaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorjdhao <jdhao@hotmail.com>2021-08-08 22:05:16 +0800
committerjdhao <jdhao@hotmail.com>2021-08-08 22:06:47 +0800
commitfe26dfa9c191843f884d86f2427f89d9fe4fc40f (patch)
tree5eff00afbeefb78c7ec11757da3c7fb2099e43f3 /autoload
parent1ead4f782453ff275b74e62faee499edec0dc04d (diff)
Use custom git branch name for vim-airline
Airline relies on fugitive to get the branch name, but fugitive is conditionally loaded. So the branch name is not shown. We need to provide our own function to get the branch name.
Diffstat (limited to 'autoload')
-rw-r--r--autoload/utils.vim9
1 files changed, 9 insertions, 0 deletions
diff --git a/autoload/utils.vim b/autoload/utils.vim
index 900069c..5bbc7e8 100644
--- a/autoload/utils.vim
+++ b/autoload/utils.vim
@@ -159,3 +159,12 @@ function! utils#Inside_git_repo() abort
return v:true
endif
endfunction
+
+function! utils#GetGitBranch()
+ let l:res = systemlist('git rev-parse --abbrev-ref HEAD')[0]
+ if match(l:res, 'fatal') != -1
+ return ''
+ else
+ return l:res
+ endif
+endfunction