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
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
4 changed files with 27 additions and 22 deletions

View File

@ -221,9 +221,11 @@ function! airline#extensions#load()
let s:filetype_regex_overrides['^int-'] = ['vimshell','%{substitute(&ft, "int-", "", "")}']
endif
if get(g:, 'airline#extensions#branch#enabled', 1)
\ && (exists('*fugitive#head') || exists('*lawrencium#statusline') ||
\ (get(g:, 'airline#extensions#branch#use_vcscommand', 0) && exists('*VCSCommandGetStatusLine')))
if get(g:, 'airline#extensions#branch#enabled', 1) && (
\ airline#util#has_fugitive() ||
\ airline#util#has_lawrencium() ||
\ airline#util#has_vcscommand() ||
\ airline#util#has_custom_scm())
call airline#extensions#branch#init(s:ext)
call add(loaded_ext, 'branch')
endif
@ -235,7 +237,7 @@ function! airline#extensions#load()
endif
if get(g:, 'airline#extensions#fugitiveline#enabled', 1)
\ && exists('*fugitive#head')
\ && airline#util#has_fugitive()
\ && index(loaded_ext, 'bufferline') == -1
call airline#extensions#fugitiveline#init(s:ext)
call add(loaded_ext, 'fugitiveline')

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

View File

@ -103,3 +103,19 @@ function! airline#util#ignore_buf(name)
\ 'gundo|undotree|vimfiler|tagbar|nerd_tree|startify')
return match(a:name, pat) > -1
endfunction
function! airline#util#has_fugitive()
return exists('*fugitive#head') || exists('*FugitiveHead')
endfunction
function! airline#util#has_lawrencium()
return exists('*lawrencium#statusline')
endfunction
function! airline#util#has_vcscommand()
return get(g:, 'airline#extensions#branch#use_vcscommand', 0) && exists('*VCSCommandGetStatusLine')
endfunction
function! airline#util#has_custom_scm()
return !empty(get(g:, 'airline#extensions#branch#custom_head', ''))
endfunction