remove auto prefix. optimize getwinvar

This commit is contained in:
Bailey Ling 2013-08-17 17:39:06 -04:00
parent b19a29675d
commit e7c5bbb671
3 changed files with 20 additions and 13 deletions

View File

@ -28,19 +28,21 @@ function! airline#get_statusline(winnr, active)
let builder = airline#builder#new(a:active, s:highlighter)
if airline#util#getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse))
call builder.add_section('a', s:get_section(a:winnr, 'a').'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}')
call builder.add_section('b', s:get_section(a:winnr, 'b'))
call builder.add_section('c', s:get_section(a:winnr, 'c').' %#airline_file#%{&ro ? g:airline_readonly_symbol : ""}')
call builder.add_section('airline_a', s:get_section(a:winnr, 'a')
\ .'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}')
call builder.add_section('airline_b', s:get_section(a:winnr, 'b'))
call builder.add_section('airline_c', s:get_section(a:winnr, 'c')
\ .'%#airline_file#%{&ro ? g:airline_readonly_symbol : ""}')
else
call builder.add_section('c', '%f%m')
call builder.add_section('airline_c', '%f%m')
endif
call builder.split(s:get_section(a:winnr, 'gutter', '', ''))
if airline#util#getwinvar(a:winnr, 'airline_render_right', 1)
call builder.add_section('c', s:get_section(a:winnr, 'x'))
call builder.add_section('b', s:get_section(a:winnr, 'y'))
call builder.add_section('a', s:get_section(a:winnr, 'z'))
call builder.add_section('airline_c', s:get_section(a:winnr, 'x'))
call builder.add_section('airline_b', s:get_section(a:winnr, 'y'))
call builder.add_section('airline_a', s:get_section(a:winnr, 'z'))
if a:active
call builder.add_raw('%(')
call builder.add_section('warningmsg', s:get_section(a:winnr, 'warning', '', ''))

View File

@ -8,7 +8,7 @@ function! s:prototype.split(gutter)
endfunction
function! s:prototype.add_section(group, contents)
call add(self._sections, ['airline_'.a:group, a:contents])
call add(self._sections, [a:group, a:contents])
endfunction
function! s:prototype.add_raw(text)

View File

@ -1,11 +1,16 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
" for 7.2 compatibility
function! airline#util#getwinvar(winnr, key, ...)
let winvals = getwinvar(a:winnr, '')
return get(winvals, a:key, (a:0 ? a:1 : ''))
if v:version >= 703
function! airline#util#getwinvar(winnr, key, def)
return getwinvar(a:winnr, a:key, a:def)
endfunction
else
function! airline#util#getwinvar(winnr, key, def)
let winvals = getwinvar(a:winnr, '')
return get(winvals, a:key, def)
endfunction
endif
function! airline#util#exec_funcrefs(list, break_early)
" for 7.2; we cannot iterate list, hence why we use range()