diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index aa93e1e..3e416f7 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -14,6 +14,8 @@ function! airline#init#bootstrap() endif let s:loaded = 1 + let g:airline#init#bootstrapping = 1 + call s:check_defined('g:airline_left_sep', get(g:, 'airline_powerline_fonts', 0)?"":">") call s:check_defined('g:airline_left_alt_sep', get(g:, 'airline_powerline_fonts', 0)?"":">") call s:check_defined('g:airline_right_sep', get(g:, 'airline_powerline_fonts', 0)?"":"<") @@ -61,10 +63,6 @@ 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', @@ -82,6 +80,10 @@ function! airline#init#sections() call airline#parts#define_function('ffenc', 'airline#parts#ffenc') call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic', 'whitespace']) + unlet g:airline#init#bootstrapping +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']) @@ -107,7 +109,5 @@ 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 diff --git a/autoload/airline/parts.vim b/autoload/airline/parts.vim index 0a43b97..bec4504 100644 --- a/autoload/airline/parts.vim +++ b/autoload/airline/parts.vim @@ -7,7 +7,7 @@ let s:parts = {} function! airline#parts#define(key, config) let s:parts[a:key] = get(s:parts, a:key, {}) - if exists('g:airline#init#initializing_sections') + if exists('g:airline#init#bootstrapping') call extend(s:parts[a:key], a:config, 'keep') else call extend(s:parts[a:key], a:config, 'force') diff --git a/t/section.vim b/t/section.vim index d36fe5c..7781651 100644 --- a/t/section.vim +++ b/t/section.vim @@ -1,6 +1,3 @@ -call airline#init#bootstrap() -call airline#extensions#load() - function! SectionSpec() endfunction @@ -11,6 +8,11 @@ describe 'section' call airline#parts#define_function('func', 'SectionSpec') end + it 'should be able to reference default parts' + let s = airline#section#create(['paste']) + Expect s == '%{airline#util#wrap(airline#parts#paste(),0)}' + end + it 'should create sections with no separators' let s = airline#section#create(['text', 'raw', 'func']) Expect s == '%{airline#util#wrap("text",0)}raw%{airline#util#wrap(SectionSpec(),0)}' @@ -43,6 +45,7 @@ describe 'section' end it 'should parse out a section from the distro' + call airline#extensions#load() let s = airline#section#create(['whitespace']) Expect s =~ 'airline#extensions#whitespace#check' end