allow parts to be defined in the vimrc as overrides. resolves #284.

This commit is contained in:
Bailey Ling 2013-09-25 18:48:18 +00:00
parent c869665b16
commit e507f481a2
3 changed files with 22 additions and 5 deletions

View File

@ -61,6 +61,10 @@ function! airline#init#bootstrap()
\ 'modified': '+',
\ 'space': ' ',
\ }, 'keep')
endfunction
function! airline#init#sections()
let g:airline#init#initializing_sections = 1
call airline#parts#define('mode', {
\ 'function': 'airline#parts#mode',
@ -77,9 +81,7 @@ function! airline#init#bootstrap()
call airline#parts#define_raw('linenr', (g:airline_symbols.linenr).'%#__accent_bold#%4l%#__restore__#')
call airline#parts#define_function('ffenc', 'airline#parts#ffenc')
call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic', 'whitespace'])
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'])
@ -105,5 +107,7 @@ function! airline#init#sections()
if !exists('g:airline_section_warning')
let g:airline_section_warning = airline#section#create(['syntastic', 'whitespace'])
endif
unlet g:airline#init#initializing_sections
endfunction

View File

@ -7,7 +7,11 @@ let s:parts = {}
function! airline#parts#define(key, config)
let s:parts[a:key] = get(s:parts, a:key, {})
call extend(s:parts[a:key], a:config)
if exists('g:airline#init#initializing_sections')
call extend(s:parts[a:key], a:config, 'keep')
else
call extend(s:parts[a:key], a:config, 'force')
endif
endfunction
function! airline#parts#define_function(key, name)

View File

@ -6,10 +6,11 @@ function! s:clear()
endfor
endfunction
describe 'init'
call airline#init#bootstrap()
describe 'init sections'
before
call s:clear()
call airline#init#bootstrap()
call airline#init#sections()
end
@ -65,3 +66,11 @@ describe 'init'
end
end
describe 'init parts'
it 'should not redefine parts already defined'
call airline#parts#define_raw('linenr', 'bar')
call airline#init#sections()
Expect g:airline_section_z =~ 'bar'
end
end