make the separator optional for older vim versions. resolves #239.

This commit is contained in:
Bailey Ling 2013-09-10 01:34:35 +00:00
parent 55f524de77
commit bed11010ba
1 changed files with 24 additions and 10 deletions

View File

@ -28,19 +28,33 @@ function! s:build_sections(builder, context, keys)
if key == 'warning' && !a:context.active
continue
endif
" i have no idea why the warning section needs special treatment, but it's
" needed to prevent separators from showing up
if key == 'warning'
call a:builder.add_raw('%(')
endif
call a:builder.add_section('airline_'.key, s:get_section(a:context.winnr, key))
if key == 'warning'
call a:builder.add_raw('%)')
endif
call s:add_section(a:builder, a:context, key)
endfor
endfunction
if v:version >= 704 || (v:version >= 703 && has('patch81'))
function s:add_section(builder, context, key)
" i have no idea why the warning section needs special treatment, but it's
" needed to prevent separators from showing up
if a:key == 'warning'
call a:builder.add_raw('%(')
endif
call a:builder.add_section('airline_'.a:key, s:get_section(a:context.winnr, a:key))
if a:key == 'warning'
call a:builder.add_raw('%)')
endif
endfunction
else
" older version don't like the use of %(%)
function s:add_section(builder, context, key)
if a:key == 'warning'
call a:builder.add_raw('%#airline_warning#'.s:get_section(a:context.winnr, a:key))
else
call a:builder.add_section('airline_'.a:key, s:get_section(a:context.winnr, a:key))
endif
endfunction
endif
function! airline#extensions#default#apply(builder, context)
let winnr = a:context.winnr
let active = a:context.active