From e0c74f9a1e6436e4c1a6ae6b1dccc7783a3b11e9 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Tue, 9 Jul 2013 00:51:33 +0000 Subject: [PATCH] add netrw support. resolves #31. --- autoload/airline.vim | 10 ++++++---- autoload/airline/extensions.vim | 31 ++++++++++++++++++++++++++----- plugin/airline.vim | 2 +- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 583060d..4f2f4c0 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -67,6 +67,8 @@ function! s:apply_window_overrides() let w:airline_section_b = '' let w:airline_section_c = bufname(winbufnr(winnr())) endif + + call airline#extensions#apply_window_overrides() endfunction function! airline#update_externals() @@ -106,13 +108,13 @@ function! airline#update_statusline(active) let sl.=l:info_sep_color let sl.=g:airline_left_sep let sl.=l:status_color.' '.s:get_section('c').' ' - let sl.=s:get_section('gutter') != '' + let sl.=exists('w:airline_section_gutter') \ ? s:get_section('gutter') - \ : '%#warningmsg#'.g:airline_externals_syntastic.l:status_color."%<%=".l:file_flag_color."%{&ro ? g:airline_readonly_symbol : ''}".l:status_color + \ : '%#warningmsg#'.g:airline_externals_syntastic.l:file_flag_color."%{&ro ? g:airline_readonly_symbol : ''}".l:status_color else - let sl.=' %f%<%=' + let sl.=' %f' endif - let sl.=' '.s:get_section('x').' ' + let sl.='%<%= '.s:get_section('x').' ' let sl.=l:info_sep_color let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep let sl.=l:info_color diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 1f6c81d..958d916 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -1,10 +1,7 @@ +let s:sections = ['a','b','c','gutter','x','y','z'] + function! airline#extensions#load() let g:unite_force_overwrite_statusline = 0 - autocmd FileType unite - \ let w:airline_section_a = 'Unite' - \ | let w:airline_section_b = unite#get_status_string() - \ | call airline#update_statusline(1) - \ | unlet w:airline_section_a | unlet w:airline_section_b if exists('g:loaded_ctrlp') && g:loaded_ctrlp call airline#extensions#ctrlp#load_ctrlp_hi() @@ -14,3 +11,27 @@ function! airline#extensions#load() \ } endif endfunction + +function! s:empty_sections() + for section in s:sections + let w:airline_section_{section} = '' + endfor +endfunction + +function! airline#extensions#apply_window_overrides() + for section in s:sections + silent! unlet w:airline_section_{section} + endfor + + if &ft == 'netrw' + let w:airline_section_a = 'netrw' + let w:airline_section_b = '%f' + let w:airline_section_c = '' + let w:airline_section_gutter = '' + let w:airline_section_x = '' + elseif &ft == 'unite' + call s:empty_sections() + let w:airline_section_a = 'Unite' + let w:airline_section_b = unite#get_status_string() + endif +endfunction diff --git a/plugin/airline.vim b/plugin/airline.vim index 3dca503..4c21f73 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -21,7 +21,7 @@ call s:check_defined('g:airline_linecolumn_prefix', exists('g:airline_powerline_ call s:check_defined('g:airline_paste_symbol', (exists('g:airline_powerline_fonts') ? ' ' : '').'PASTE') call s:check_defined('g:airline_theme', 'dark') call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus']) -call s:check_defined('g:airline_exclude_filetypes', ['netrw','diff','undotree','gundo','nerdtree','tagbar']) +call s:check_defined('g:airline_exclude_filetypes', ['diff','undotree','gundo','nerdtree','tagbar']) call s:check_defined('g:airline_mode_map', { \ 'n' : 'NORMAL',