branch: fugitive renamed its functions

this caused that the branch extension was not correctly working anymore
because of a refactoring of fugitive tpope/vim-fugitive@5d11ff7

Solution: Move the existence check for the fugitive plugin into a
separate function and call it from there in all places that check the
fugitive plugin. Do the same for lawrencium and vcscommand check.

fixes #605 #1739
This commit is contained in:
Christian Brabandt
2018-06-04 17:31:13 +02:00
parent 08570b6dcb
commit 30a3c4f549
4 changed files with 27 additions and 22 deletions

View File

@@ -3,19 +3,6 @@
scriptencoding utf-8
function! s:has_fugitive()
return exists('*fugitive#head')
endfunction
function! s:has_lawrencium()
return exists('*lawrencium#statusline')
endfunction
function! s:has_vcscommand()
return get(g:, 'airline#extensions#branch#use_vcscommand', 0) && exists('*VCSCommandGetStatusLine')
endfunction
function! s:has_custom_scm()
return !empty(get(g:, 'airline#extensions#branch#custom_head', ''))
endfunction
" s:vcs_config contains static configuration of VCSes and their status relative
" to the active file.
" 'branch' - The name of currently active branch. This field is empty iff it
@@ -94,7 +81,7 @@ let s:names = {'0': 'index', '1': 'orig', '2':'fetch', '3':'merge'}
let s:sha1size = get(g:, 'airline#extensions#branch#sha1_len', 7)
function! s:update_git_branch()
if !s:has_fugitive()
if !airline#util#has_fugitive()
let s:vcs_config['git'].branch = ''
return
endif
@@ -128,7 +115,7 @@ function! s:display_git_branch()
endfunction
function! s:update_hg_branch()
if s:has_lawrencium()
if airline#util#has_lawrencium()
let cmd='LC_ALL=C hg qtop'
let stl=lawrencium#statusline()
let file=expand('%:p')
@@ -253,7 +240,7 @@ function! airline#extensions#branch#head()
endfor
if empty(heads)
if s:has_vcscommand()
if airline#util#has_vcscommand()
call VCSCommandEnableBufferSetup()
if exists('b:VCSCommandBufferInfo')
let b:airline_head = s:format_name(get(b:VCSCommandBufferInfo, 0, ''))
@@ -262,7 +249,7 @@ function! airline#extensions#branch#head()
endif
if empty(heads)
if s:has_custom_scm()
if airline#util#has_custom_scm()
try
let Fn = function(g:airline#extensions#branch#custom_head)
let b:airline_head = Fn()

View File

@@ -3,7 +3,7 @@
scriptencoding utf-8
if !exists('*fugitive#head')
if !airline#util#has_fugitive()
finish
endif