define default statusline items with empty contents.

This commit is contained in:
Bailey Ling 2013-08-31 03:35:23 +00:00
parent 500ecf7cd0
commit a13c692529
3 changed files with 36 additions and 22 deletions

View File

@ -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')

View File

@ -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

View File

@ -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