From c98549913c19b9db632bc214bc4266a17fa103ae Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 24 Aug 2013 09:47:16 -0400 Subject: [PATCH] remove hackfix and use new tagbar statusline integration. requires https://github.com/majutsushi/tagbar/commit/0b14e28719e83e70241521df013ffec33b73ca3e --- autoload/airline/extensions/tagbar.vim | 29 +++++++++++--------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/autoload/airline/extensions/tagbar.vim b/autoload/airline/extensions/tagbar.vim index bb957bc..f1ad0e7 100644 --- a/autoload/airline/extensions/tagbar.vim +++ b/autoload/airline/extensions/tagbar.vim @@ -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 check_statusline() - augroup END endfunction