From bed11010baaf670e2c1688c166876ab4ee092129 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Tue, 10 Sep 2013 01:34:35 +0000 Subject: [PATCH] make the separator optional for older vim versions. resolves #239. --- autoload/airline/extensions/default.vim | 34 +++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/autoload/airline/extensions/default.vim b/autoload/airline/extensions/default.vim index db3384a5..a3e0c580 100644 --- a/autoload/airline/extensions/default.vim +++ b/autoload/airline/extensions/default.vim @@ -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