mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-23 07:31:15 +08:00
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:
parent
08570b6dcb
commit
30a3c4f549
|
@ -221,9 +221,11 @@ function! airline#extensions#load()
|
||||||
let s:filetype_regex_overrides['^int-'] = ['vimshell','%{substitute(&ft, "int-", "", "")}']
|
let s:filetype_regex_overrides['^int-'] = ['vimshell','%{substitute(&ft, "int-", "", "")}']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get(g:, 'airline#extensions#branch#enabled', 1)
|
if get(g:, 'airline#extensions#branch#enabled', 1) && (
|
||||||
\ && (exists('*fugitive#head') || exists('*lawrencium#statusline') ||
|
\ airline#util#has_fugitive() ||
|
||||||
\ (get(g:, 'airline#extensions#branch#use_vcscommand', 0) && exists('*VCSCommandGetStatusLine')))
|
\ airline#util#has_lawrencium() ||
|
||||||
|
\ airline#util#has_vcscommand() ||
|
||||||
|
\ airline#util#has_custom_scm())
|
||||||
call airline#extensions#branch#init(s:ext)
|
call airline#extensions#branch#init(s:ext)
|
||||||
call add(loaded_ext, 'branch')
|
call add(loaded_ext, 'branch')
|
||||||
endif
|
endif
|
||||||
|
@ -235,7 +237,7 @@ function! airline#extensions#load()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get(g:, 'airline#extensions#fugitiveline#enabled', 1)
|
if get(g:, 'airline#extensions#fugitiveline#enabled', 1)
|
||||||
\ && exists('*fugitive#head')
|
\ && airline#util#has_fugitive()
|
||||||
\ && index(loaded_ext, 'bufferline') == -1
|
\ && index(loaded_ext, 'bufferline') == -1
|
||||||
call airline#extensions#fugitiveline#init(s:ext)
|
call airline#extensions#fugitiveline#init(s:ext)
|
||||||
call add(loaded_ext, 'fugitiveline')
|
call add(loaded_ext, 'fugitiveline')
|
||||||
|
|
|
@ -3,19 +3,6 @@
|
||||||
|
|
||||||
scriptencoding utf-8
|
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
|
" s:vcs_config contains static configuration of VCSes and their status relative
|
||||||
" to the active file.
|
" to the active file.
|
||||||
" 'branch' - The name of currently active branch. This field is empty iff it
|
" '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)
|
let s:sha1size = get(g:, 'airline#extensions#branch#sha1_len', 7)
|
||||||
|
|
||||||
function! s:update_git_branch()
|
function! s:update_git_branch()
|
||||||
if !s:has_fugitive()
|
if !airline#util#has_fugitive()
|
||||||
let s:vcs_config['git'].branch = ''
|
let s:vcs_config['git'].branch = ''
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
@ -128,7 +115,7 @@ function! s:display_git_branch()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:update_hg_branch()
|
function! s:update_hg_branch()
|
||||||
if s:has_lawrencium()
|
if airline#util#has_lawrencium()
|
||||||
let cmd='LC_ALL=C hg qtop'
|
let cmd='LC_ALL=C hg qtop'
|
||||||
let stl=lawrencium#statusline()
|
let stl=lawrencium#statusline()
|
||||||
let file=expand('%:p')
|
let file=expand('%:p')
|
||||||
|
@ -253,7 +240,7 @@ function! airline#extensions#branch#head()
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
if empty(heads)
|
if empty(heads)
|
||||||
if s:has_vcscommand()
|
if airline#util#has_vcscommand()
|
||||||
call VCSCommandEnableBufferSetup()
|
call VCSCommandEnableBufferSetup()
|
||||||
if exists('b:VCSCommandBufferInfo')
|
if exists('b:VCSCommandBufferInfo')
|
||||||
let b:airline_head = s:format_name(get(b:VCSCommandBufferInfo, 0, ''))
|
let b:airline_head = s:format_name(get(b:VCSCommandBufferInfo, 0, ''))
|
||||||
|
@ -262,7 +249,7 @@ function! airline#extensions#branch#head()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if empty(heads)
|
if empty(heads)
|
||||||
if s:has_custom_scm()
|
if airline#util#has_custom_scm()
|
||||||
try
|
try
|
||||||
let Fn = function(g:airline#extensions#branch#custom_head)
|
let Fn = function(g:airline#extensions#branch#custom_head)
|
||||||
let b:airline_head = Fn()
|
let b:airline_head = Fn()
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
if !exists('*fugitive#head')
|
if !airline#util#has_fugitive()
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -103,3 +103,19 @@ function! airline#util#ignore_buf(name)
|
||||||
\ 'gundo|undotree|vimfiler|tagbar|nerd_tree|startify')
|
\ 'gundo|undotree|vimfiler|tagbar|nerd_tree|startify')
|
||||||
return match(a:name, pat) > -1
|
return match(a:name, pat) > -1
|
||||||
endfunction
|
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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user