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