From dcb71960975e388d6cce8f1b6d0ca4f3bbf06829 Mon Sep 17 00:00:00 2001 From: bootleq Date: Sat, 3 Aug 2013 09:17:53 +0800 Subject: [PATCH 1/3] Add padding spaces for section in s:get_section. When section text is non-empty, pad spaces before/after it. --- autoload/airline.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 5f0e653..09e800a 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -94,7 +94,8 @@ function! s:getwinvar(winnr, key, ...) endfunction function! s:get_section(winnr, key) - return s:getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) + let text = s:getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) + return empty(text) ? '' : ' '.text.' ' endfunction function! s:get_statusline(winnr, active) From 5ebb0daf937d0617dbabaa0825ac3a29f17a824b Mon Sep 17 00:00:00 2001 From: bootleq Date: Sat, 3 Aug 2013 09:42:18 +0800 Subject: [PATCH 2/3] Add prefix/suffix options for s:get_section. For output format other than default 1 space padding. Need this to keep original section_c style: let sl.=l:status_color.' %<'.s:get_section(a:winnr, 'c').' ' --- autoload/airline.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 09e800a..7e60706 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -93,9 +93,10 @@ function! s:getwinvar(winnr, key, ...) return get(winvals, a:key, (a:0 ? a:1 : '')) endfunction -function! s:get_section(winnr, key) +function! s:get_section(winnr, key, ...) let text = s:getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) - return empty(text) ? '' : ' '.text.' ' + let [prefix, suffix] = [get(a:000, 0, ' '), get(a:000, 1, ' ')] + return empty(text) ? '' : prefix.text.suffix endfunction function! s:get_statusline(winnr, active) From 410792ed48d713f5361aa58960cd9efb0570874d Mon Sep 17 00:00:00 2001 From: bootleq Date: Sat, 3 Aug 2013 10:00:56 +0800 Subject: [PATCH 3/3] Remove space-padding works outside of get_section. --- autoload/airline.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 7e60706..a991947 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -109,15 +109,15 @@ function! s:get_statusline(winnr, active) let sl = '%{airline#update_highlight()}' if a:active || s:getwinvar(a:winnr, 'airline_left_only', 0) - let sl.=l:mode_color.' '.s:get_section(a:winnr, 'a').' ' + let sl.=l:mode_color.s:get_section(a:winnr, 'a') let sl.='%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}' let sl.=l:mode_sep_color let sl.=a:active ? g:airline_left_sep : g:airline_left_alt_sep let sl.=l:info_color - let sl.=' '.s:get_section(a:winnr, 'b').' ' + let sl.=s:get_section(a:winnr, 'b') let sl.=l:info_sep_color let sl.=g:airline_left_sep - let sl.=l:status_color.' %<'.s:get_section(a:winnr, 'c').' ' + let sl.=l:status_color.s:get_section(a:winnr, 'c', ' %<') let gutter = s:getwinvar(a:winnr, 'airline_section_gutter', get(g:, 'airline_section_gutter', '')) let sl.=gutter != '' \ ? gutter @@ -127,15 +127,15 @@ function! s:get_statusline(winnr, active) endif if !s:getwinvar(a:winnr, 'airline_left_only', 0) let sl.='%=' - let sl.=' '.s:get_section(a:winnr, 'x').' ' + let sl.=s:get_section(a:winnr, '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 - let sl.=' '.s:get_section(a:winnr, 'y').' ' + let sl.=s:get_section(a:winnr, 'y') let sl.=l:mode_sep_color let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep let sl.=l:mode_color - let sl.=' '.s:get_section(a:winnr, 'z').' ' + let sl.=s:get_section(a:winnr, 'z') endif return sl endfunction