From 12ea154de8ebedad22f967d6e3047a32c3852e09 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Wed, 18 Sep 2013 22:23:50 -0400 Subject: [PATCH 1/2] use code 160 for space to fix rendering problems. --- autoload/airline/extensions/branch.vim | 2 +- autoload/airline/init.vim | 6 ++++-- autoload/airline/section.vim | 5 +++-- autoload/airline/util.vim | 5 +++-- t/section.vim | 8 ++++---- t/util.vim | 8 ++++---- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index 9da7b68..52e72a6 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -33,7 +33,7 @@ function! airline#extensions#branch#get_head() return empty(head) || !s:check_in_path() \ ? s:empty_message - \ : printf('%s%s', empty(s:symbol) ? '' : s:symbol.' ', head) + \ : printf('%s%s', empty(s:symbol) ? '' : s:symbol.(g:airline_symbols.space), head) endfunction function! s:check_in_path() diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index a5a5958..60d7ba8 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -56,6 +56,7 @@ function! airline#init#bootstrap() \ 'linenr': get(g:, 'airline_linecolumn_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ':' ), \ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ''), \ 'modified': '+', + \ 'space': ' ', \ }, 'keep') call airline#parts#define_function('mode', 'airline#parts#mode') @@ -72,6 +73,7 @@ function! airline#init#bootstrap() endfunction function! airline#init#sections() + let spc = g:airline_symbols.space if !exists('g:airline_section_a') let g:airline_section_a = airline#section#create_left(['mode', 'paste', 'iminsert']) endif @@ -82,7 +84,7 @@ function! airline#init#sections() let g:airline_section_c = airline#section#create(['%<', 'file']) endif if !exists('g:airline_section_gutter') - let g:airline_section_gutter = airline#section#create([' ', 'readonly', '%=']) + let g:airline_section_gutter = airline#section#create([spc, 'readonly', '%=']) endif if !exists('g:airline_section_x') let g:airline_section_x = airline#section#create_right(['tagbar', 'filetype']) @@ -91,7 +93,7 @@ function! airline#init#sections() let g:airline_section_y = airline#section#create_right(['ffenc']) endif if !exists('g:airline_section_z') - let g:airline_section_z = airline#section#create_right(['%3p%% %{g:airline_symbols.linenr} %3l:%3c ']) + let g:airline_section_z = airline#section#create_right(['%3p%%'.spc.(g:airline_symbols.linenr).spc.'%3l:%3c'.spc]) endif if !exists('g:airline_section_warning') let g:airline_section_warning = airline#section#create(['syntastic', 'whitespace']) diff --git a/autoload/airline/section.vim b/autoload/airline/section.vim index 516d000..6299e32 100644 --- a/autoload/airline/section.vim +++ b/autoload/airline/section.vim @@ -2,6 +2,7 @@ " vim: et ts=2 sts=2 sw=2 call airline#init#bootstrap() +let s:spc = g:airline_symbols.space function! s:create(parts, append) let _ = '' @@ -19,10 +20,10 @@ function! s:create(parts, append) let func = '"'.(part.text).'"' else if a:append > 0 && idx != 0 - let val .= ' '.g:airline_left_alt_sep.' ' + let val .= s:spc.g:airline_left_alt_sep.s:spc endif if a:append < 0 && idx != 0 - let val = ' '.g:airline_right_alt_sep.' '.val + let val = s:spc.g:airline_right_alt_sep.s:spc.val endif if exists('part.raw') let _ .= val.(part.raw) diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim index fbc06d9..47cddfa 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -2,6 +2,7 @@ " vim: et ts=2 sts=2 sw=2 call airline#init#bootstrap() +let s:spc = g:airline_symbols.space function! airline#util#wrap(text, minwidth) if a:minwidth > 0 && winwidth(0) < a:minwidth @@ -14,14 +15,14 @@ function! airline#util#append(text, minwidth) if a:minwidth > 0 && winwidth(0) < a:minwidth return '' endif - return empty(a:text) ? '' : ' '.g:airline_left_alt_sep.' '.a:text + return empty(a:text) ? '' : s:spc.g:airline_left_alt_sep.s:spc.a:text endfunction function! airline#util#prepend(text, minwidth) if a:minwidth > 0 && winwidth(0) < a:minwidth return '' endif - return empty(a:text) ? '' : a:text.' '.g:airline_right_alt_sep.' ' + return empty(a:text) ? '' : a:text.s:spc.g:airline_right_alt_sep.s:spc endfunction if v:version >= 704 diff --git a/t/section.vim b/t/section.vim index de9f208..3bf9f3f 100644 --- a/t/section.vim +++ b/t/section.vim @@ -47,13 +47,13 @@ describe 'section' it 'should force add separators for raw and missing keys' let s = airline#section#create_left(['asdf', 'raw']) - Expect s == 'asdf > raw' + Expect s == 'asdf > raw' let s = airline#section#create_left(['asdf', 'aaaa', 'raw']) - Expect s == 'asdf > aaaa > raw' + Expect s == 'asdf > aaaa > raw' let s = airline#section#create_right(['raw', '%f']) - Expect s == 'raw < %f' + Expect s == 'raw < %f' let s = airline#section#create_right(['%t', 'asdf', '%{getcwd()}']) - Expect s == '%t < asdf < %{getcwd()}' + Expect s == '%t < asdf < %{getcwd()}' end it 'should empty out parts that do not pass their condition' diff --git a/t/util.vim b/t/util.vim index 913de9d..c438f2f 100644 --- a/t/util.vim +++ b/t/util.vim @@ -17,12 +17,12 @@ describe 'util' it 'has append wrapper function' Expect airline#util#append('', 0) == '' - Expect airline#util#append('1', 0) == ' > 1' + Expect airline#util#append('1', 0) == ' > 1' end it 'has prepend wrapper function' Expect airline#util#prepend('', 0) == '' - Expect airline#util#prepend('1', 0) == '1 < ' + Expect airline#util#prepend('1', 0) == '1 < ' end it 'has getwinvar function' @@ -40,8 +40,8 @@ describe 'util' end it 'should ignore minwidth if less than 0' - Expect airline#util#append('foo', -1) == ' > foo' - Expect airline#util#prepend('foo', -1) == 'foo < ' + Expect airline#util#append('foo', -1) == ' > foo' + Expect airline#util#prepend('foo', -1) == 'foo < ' Expect airline#util#wrap('foo', -1) == 'foo' end From bfe35ed76cbbfb8eaed54ade209647fcd217a155 Mon Sep 17 00:00:00 2001 From: bling Date: Sun, 22 Sep 2013 11:29:27 -0400 Subject: [PATCH 2/2] replace all instance of space with the no-break space. resolves #256. --- autoload/airline/extensions/bufferline.vim | 2 +- autoload/airline/extensions/ctrlp.vim | 2 +- autoload/airline/extensions/default.vim | 3 ++- autoload/airline/extensions/example.vim | 6 +++++- autoload/airline/extensions/syntastic.vim | 2 +- autoload/airline/extensions/tabline.vim | 2 +- autoload/airline/extensions/tagbar.vim | 7 ++++--- autoload/airline/extensions/virtualenv.vim | 5 ++++- autoload/airline/extensions/whitespace.vim | 4 ++-- 9 files changed, 21 insertions(+), 12 deletions(-) diff --git a/autoload/airline/extensions/bufferline.vim b/autoload/airline/extensions/bufferline.vim index cb9e1b3..0c6013c 100644 --- a/autoload/airline/extensions/bufferline.vim +++ b/autoload/airline/extensions/bufferline.vim @@ -15,7 +15,7 @@ function! airline#extensions#bufferline#init(ext) let g:bufferline_active_highlight = 'bufferline_selected' let g:bufferline_active_buffer_left = '' let g:bufferline_active_buffer_right = '' - let g:bufferline_separator = ' ' + let g:bufferline_separator = g:airline_symbols.space endif call airline#parts#define_raw('file', '%{bufferline#refresh_status()}'.bufferline#get_status_string()) diff --git a/autoload/airline/extensions/ctrlp.vim b/autoload/airline/extensions/ctrlp.vim index 851b0b7..e114ae5 100644 --- a/autoload/airline/extensions/ctrlp.vim +++ b/autoload/airline/extensions/ctrlp.vim @@ -39,7 +39,7 @@ function! airline#extensions#ctrlp#ctrlp_airline(...) let prv = '%#CtrlPlight# '.a:4.' %#Ctrlparrow1#'.g:airline_left_sep let item = '%#CtrlPwhite# '.a:5.' %#CtrlParrow2#'.g:airline_left_sep let nxt = '%#CtrlPlight# '.a:6.' %#CtrlParrow3#'.g:airline_left_sep - let marked = '%#CtrlPdark# '.a:7.' ' + let marked = '%#CtrlPdark# '.a:7.(g:airline_symbols.space) let focus = '%=%<%#CtrlPdark# '.a:1.' %*' let byfname = '%#CtrlParrow3#'.g:airline_right_alt_sep.'%#CtrlPdark# '.a:2.' %*' let dir = '%#CtrlParrow3#'.g:airline_right_sep.'%#CtrlPlight# '.getcwd().' %*' diff --git a/autoload/airline/extensions/default.vim b/autoload/airline/extensions/default.vim index 817d941..1fe889a 100644 --- a/autoload/airline/extensions/default.vim +++ b/autoload/airline/extensions/default.vim @@ -11,6 +11,7 @@ let s:layout = get(g:, 'airline#extensions#default#layout', [ \ [ 'a', 'b', 'c' ], \ [ 'x', 'y', 'z', 'warning' ] \ ]) +let s:spc = g:airline_symbols.space function! s:get_section(winnr, key, ...) if has_key(s:section_truncate_width, a:key) @@ -19,7 +20,7 @@ function! s:get_section(winnr, key, ...) endif endif let text = airline#util#getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) - let [prefix, suffix] = [get(a:000, 0, '%( '), get(a:000, 1, ' %)')] + let [prefix, suffix] = [get(a:000, 0, '%('.s:spc), get(a:000, 1, s:spc.'%)')] return empty(text) ? '' : prefix.text.suffix endfunction diff --git a/autoload/airline/extensions/example.vim b/autoload/airline/extensions/example.vim index 09083dd..0c64f2c 100644 --- a/autoload/airline/extensions/example.vim +++ b/autoload/airline/extensions/example.vim @@ -4,6 +4,10 @@ " we don't actually want this loaded :P finish +" Due to some potential rendering issues, the use of the `space` variable is +" recommended. +let s:spc = g:airline_symbols.space + " Extension specific variables can be defined the usual fashion. if !exists('g:airline#extensions#example#number_of_cats') let g:airline#extensions#example#number_of_cats = 42 @@ -35,7 +39,7 @@ function! airline#extensions#example#apply(...) let w:airline_section_c = get(w:, 'airline_section_c', g:airline_section_c) " Then we just append this extenion to it, optionally using separators. - let w:airline_section_c .= ' '.g:airline_left_alt_sep.' %{airline#extensions#example#get_cats()}' + let w:airline_section_c .= s:spc.g:airline_left_alt_sep.s:spc.'%{airline#extensions#example#get_cats()}' endif endfunction diff --git a/autoload/airline/extensions/syntastic.vim b/autoload/airline/extensions/syntastic.vim index 4e35f0d..3ecc1eb 100644 --- a/autoload/airline/extensions/syntastic.vim +++ b/autoload/airline/extensions/syntastic.vim @@ -8,7 +8,7 @@ endif function! airline#extensions#syntastic#get_warnings() let errors = SyntasticStatuslineFlag() if strlen(errors) > 0 - return errors.' ' + return errors.(g:airline_symbols.space) endif return '' endfunction diff --git a/autoload/airline/extensions/tabline.vim b/autoload/airline/extensions/tabline.vim index 205a64c..3c54778 100644 --- a/autoload/airline/extensions/tabline.vim +++ b/autoload/airline/extensions/tabline.vim @@ -168,7 +168,7 @@ function! s:get_tabs() if s:tab_nr_type == 0 let val .= ' %{len(tabpagebuflist('.i.'))}' else - let val .= ' '.i + let val .= (g:airline_symbols.space).i endif call b.add_section(group, val.'%'.i.'T %{airline#extensions#tabline#title('.i.')} %)') endfor diff --git a/autoload/airline/extensions/tagbar.vim b/autoload/airline/extensions/tagbar.vim index d786abf..061a47f 100644 --- a/autoload/airline/extensions/tagbar.vim +++ b/autoload/airline/extensions/tagbar.vim @@ -6,13 +6,14 @@ if !exists(':TagbarToggle') endif let s:flags = get(g:, 'airline#extensions#tagbar#flags', '') +let s:spc = g:airline_symbols.space " Arguments: current, sort, fname function! airline#extensions#tagbar#get_status(...) let builder = airline#builder#new({ 'active': a:1 }) - call builder.add_section('airline_a', ' Tagbar ') - call builder.add_section('airline_b', ' '.a:2.' ') - call builder.add_section('airline_c', ' '.a:3.' ') + call builder.add_section('airline_a', s:spc.'Tagbar'.s:spc) + call builder.add_section('airline_b', s:spc.a:2.s:spc) + call builder.add_section('airline_c', s:spc.a:3.s:spc) return builder.build() endfunction diff --git a/autoload/airline/extensions/virtualenv.vim b/autoload/airline/extensions/virtualenv.vim index 7b564a9..c052282 100644 --- a/autoload/airline/extensions/virtualenv.vim +++ b/autoload/airline/extensions/virtualenv.vim @@ -5,13 +5,16 @@ if !get(g:, 'virtualenv_loaded', 0) finish endif +let s:spc = g:airline_symbols.space + function! airline#extensions#virtualenv#init(ext) call a:ext.add_statusline_func('airline#extensions#virtualenv#apply') endfunction function! airline#extensions#virtualenv#apply(...) if &filetype =~ "python" - call airline#extensions#append_to_section('x', ' '.g:airline_right_alt_sep.' %{virtualenv#statusline()}') + call airline#extensions#append_to_section('x', + \ s:spc.g:airline_right_alt_sep.s:spc.'%{virtualenv#statusline()}') endif endfunction diff --git a/autoload/airline/extensions/whitespace.vim b/autoload/airline/extensions/whitespace.vim index a9d9cb0..99dfd76 100644 --- a/autoload/airline/extensions/whitespace.vim +++ b/autoload/airline/extensions/whitespace.vim @@ -41,11 +41,11 @@ function! airline#extensions#whitespace#check() let b:airline_whitespace_check = s:symbol if s:show_message if trailing != 0 - let b:airline_whitespace_check .= ' '.printf(s:trailing_format, trailing) + let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:trailing_format, trailing) endif if mixed let mixnr = indents[0] == indents[1] ? indents[0] : indents[2] - let b:airline_whitespace_check .= ' '.printf(s:mixed_indent_format, mixnr) + let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:mixed_indent_format, mixnr) endif endif endif