diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 702bf75..2ff03f4 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -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') diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index e589d23..1bb0773 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -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() diff --git a/autoload/airline/extensions/fugitiveline.vim b/autoload/airline/extensions/fugitiveline.vim index 289121d..744b903 100644 --- a/autoload/airline/extensions/fugitiveline.vim +++ b/autoload/airline/extensions/fugitiveline.vim @@ -3,7 +3,7 @@ scriptencoding utf-8 -if !exists('*fugitive#head') +if !airline#util#has_fugitive() finish endif diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim index b8f39b0..2261510 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -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