remove hackfix and use new tagbar statusline integration.

requires 0b14e28719
This commit is contained in:
Bailey Ling 2013-08-24 09:47:16 -04:00
parent 0e6035f75c
commit c98549913c
1 changed files with 12 additions and 17 deletions

View File

@ -1,31 +1,26 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
function! airline#extensions#tagbar#apply(...)
if &ft == 'tagbar'
call airline#extensions#apply_left_override('Tagbar', '%{TagbarGenerateStatusline()}')
endif
" Arguments: current, sort, fname
function! airline#extensions#tagbar#get_status(...)
let builder = airline#builder#new({ 'active': a:1 })
call builder.add_section('airline_a', ' Tagbar ')
call builder.add_section('airline_b', ' '.a:2.' ')
call builder.add_section('airline_c', ' '.a:3.' ')
return builder.build()
endfunction
function! s:check_statusline()
" this is a hack!! unlike most plugins that set eventignore=all, tagbar only
" sets it to BufEnter, so the ordering is off: airline sets the statusline
" first, and then tagbar overwrites it, so this detects that and changes it
" back to the airline statusline.
if exists('#airline') && match(&statusline, '^%!Tagbar') >= 0
call airline#update_statusline()
function! airline#extensions#tagbar#inactive_apply(...)
if getwinvar(a:2.winnr, '&filetype') == 'tagbar'
return -1
endif
endfunction
function! airline#extensions#tagbar#init(ext)
call a:ext.add_statusline_func('airline#extensions#tagbar#apply')
call a:ext.add_inactive_statusline_func('airline#extensions#tagbar#inactive_apply')
let g:tagbar_status_func = 'airline#extensions#tagbar#get_status'
let g:airline_section_x = '%(%{get(w:,"airline_active",0) ? tagbar#currenttag("%s","") : ""} '
\ .g:airline_right_alt_sep.' %)'.g:airline_section_x
augroup airline_tagbar
autocmd!
autocmd CursorMoved * call <sid>check_statusline()
augroup END
endfunction