diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index 8302e6e8..c1ac79f1 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -20,25 +20,6 @@ function! airline#init#bootstrap() call s:check_defined('g:airline_exclude_filetypes', []) call s:check_defined('g:airline_exclude_preview', 0) - call s:check_defined('g:airline_symbols', {}) - call extend(g:airline_symbols, { - \ 'paste': get(g:, 'airline_paste_symbol', 'PASTE'), - \ 'readonly': get(g:, 'airline_readonly_symbol', get(g:, 'airline_powerline_fonts', 0) ? '' : 'RO'), - \ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? '✹' : '!', - \ 'linenr': get(g:, 'airline_linecolumn_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ':' ), - \ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ''), - \ }, 'keep') - - call airline#parts#define_function('mode', 'airline#parts#mode') - call airline#parts#define_function('iminsert', 'airline#parts#iminsert') - call airline#parts#define_function('paste', 'airline#parts#paste') - call airline#parts#define('readonly', { - \ 'function': 'airline#parts#readonly', - \ 'highlight': 'airline_file', - \ }) - call airline#parts#define_raw('file', '%f%m') - call airline#parts#define_raw('ffenc', '%{printf("%s%s",&fenc,strlen(&ff)>0?"[".&ff."]":"")}') - call s:check_defined('g:airline_mode_map', {}) call extend(g:airline_mode_map, { \ '__' : '------', @@ -62,6 +43,27 @@ function! airline#init#bootstrap() \ '.*solarized.*': 'solarized', \ }, 'keep') + call s:check_defined('g:airline_symbols', {}) + call extend(g:airline_symbols, { + \ 'paste': get(g:, 'airline_paste_symbol', 'PASTE'), + \ 'readonly': get(g:, 'airline_readonly_symbol', get(g:, 'airline_powerline_fonts', 0) ? '' : 'RO'), + \ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? '✹' : '!', + \ 'linenr': get(g:, 'airline_linecolumn_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ':' ), + \ 'branch': get(g:, 'airline_branch_prefix', get(g:, 'airline_powerline_fonts', 0) ? '' : ''), + \ }, 'keep') + + call airline#parts#define_function('mode', 'airline#parts#mode') + call airline#parts#define_function('iminsert', 'airline#parts#iminsert') + call airline#parts#define_function('paste', 'airline#parts#paste') + call airline#parts#define('readonly', { + \ 'function': 'airline#parts#readonly', + \ 'highlight': 'airline_file', + \ }) + call airline#parts#define_raw('file', '%f%m') + call airline#parts#define_raw('ffenc', '%{printf("%s%s",&fenc,strlen(&ff)>0?"[".&ff."]":"")}') + + call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic']) + call airline#extensions#load() if !exists('g:airline_section_a') diff --git a/autoload/airline/parts.vim b/autoload/airline/parts.vim index 31a9f166..39041f8d 100644 --- a/autoload/airline/parts.vim +++ b/autoload/airline/parts.vim @@ -20,6 +20,12 @@ function! airline#parts#define_raw(key, raw) call airline#parts#define(a:key, { 'raw': a:raw }) endfunction +function! airline#parts#define_empty(keys) + for key in a:keys + call airline#parts#define_raw(key, '') + endfor +endfunction + function! airline#parts#get(key) return get(s:parts, a:key, {}) endfunction diff --git a/t/init.vim b/t/init.vim index 72a42f66..f5293811 100644 --- a/t/init.vim +++ b/t/init.vim @@ -22,9 +22,8 @@ describe 'init' Expect g:airline_section_a =~ 'iminsert' end - it 'section b should have hunks and branch' - Expect g:airline_section_b =~ 'hunks' - Expect g:airline_section_b =~ 'branch' + it 'section b should be blank because no extensions are installed' + Expect g:airline_section_b == '' end it 'section c should be file' @@ -55,5 +54,12 @@ describe 'init' Expect g:airline_section_{s} == s endfor end + + it 'all default statusline extensions should be blank' + Expect airline#parts#get('hunks').raw == '' + Expect airline#parts#get('branch').raw == '' + Expect airline#parts#get('tagbar').raw == '' + Expect airline#parts#get('syntastic').raw == '' + end end