update documentation about section functions.

This commit is contained in:
Bailey Ling 2013-09-01 13:59:22 -04:00
parent 92de8ad160
commit d6599d0b3b
2 changed files with 8 additions and 6 deletions

View File

@ -307,13 +307,15 @@ Note: Look at the source code and tests for the full API.
Once a part is defined, you can use helper functions to generate the Once a part is defined, you can use helper functions to generate the
statuslines for each section. For example, to use the part above, we could statuslines for each section. For example, to use the part above, we could
define a section like this: > define a section like this: >
autocmd VimEnter * function! AirlineInit()
\ let g:airline_section_a = airline#section#create(['mode', ' ', 'foo']) let g:airline_section_a = airline#section#create(['mode', ' ', 'foo'])
let g:airline_section_b = airline#section#create_left(['ffenc','file'])
endfunction
autocmd VimEnter * call AirlineInit()
< <
This will create a section with the `mode`, followed by a space, and our `foo` This will create a section with the `mode`, followed by a space, and our `foo`
component. There are other functions that take care of putting in separators part in section `a`. Section `b` will have two parts with a left-side
in the right place for the left and right side. Have a look at the code/tests separator. Have a look at the code/tests for all available options.
for all available options.
Note: The use of `VimEnter` is important, because most extensions are lazily Note: The use of `VimEnter` is important, because most extensions are lazily
loaded, so we must give them a chance to define their parts before we can use loaded, so we must give them a chance to define their parts before we can use

View File

@ -32,7 +32,7 @@ describe 'init'
end end
it 'section x should be filetype' it 'section x should be filetype'
Expect g:airline_section_x =~ '&filetype' Expect g:airline_section_x == '%{airline#util#wrap(airline#parts#filetype(),0)}'
end end
it 'section y should be fenc and ff' it 'section y should be fenc and ff'