diff --git a/doc/airline.txt b/doc/airline.txt index 66aa6d4e..7449c39c 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -14,16 +14,17 @@ CONTENTS *airline-contents* 03. Name ................................................. |airline-name| 04. Configuration ............................... |airline-configuration| 05. Commands ......................................... |airline-commands| - 06. Customization ............................... |airline-customization| - 07. Extensions ..................................... |airline-extensions| - 08. Advanced Customization ............. |airline-advanced-customization| - 09. Funcrefs ......................................... |airline-funcrefs| - 10. Pipeline ......................................... |airline-pipeline| - 11. Writing Extensions ..................... |airline-writing-extensions| - 12. Writing Themes ..................................... |airline-themes| - 13. Troubleshooting ........................... |airline-troubleshooting| - 14. Contributions ............................... |airline-contributions| - 15. License ........................................... |airline-license| + 06. Autocommands ................................. |airline-autocommands| + 07. Customization ............................... |airline-customization| + 08. Extensions ..................................... |airline-extensions| + 09. Advanced Customization ............. |airline-advanced-customization| + 10. Funcrefs ......................................... |airline-funcrefs| + 11. Pipeline ......................................... |airline-pipeline| + 12. Writing Extensions ..................... |airline-writing-extensions| + 13. Writing Themes ..................................... |airline-themes| + 14. Troubleshooting ........................... |airline-troubleshooting| + 15. Contributions ............................... |airline-contributions| + 16. License ........................................... |airline-license| ============================================================================== INTRODUCTION *airline-intro* @@ -146,6 +147,17 @@ COMMANDS *airline-commands* :AirlineRefresh *:AirlineRefresh* Refreshes all highlight groups and redraws the statusline. +============================================================================== +AUTOCOMMANDS *airline-autocommands* + +Airline comes with some user-defined autocommands. + +|AirlineAfterInit| after plugin is initialized, but before the statusline + is replaced +|AirlineToggledOn| after airline is activated and replaced the statusline +|AirlineToggledOff| after airline is deactivated and the statusline is + restored to the original + ============================================================================== CUSTOMIZATION *airline-customization* @@ -616,7 +628,7 @@ define a section like this: > let g:airline_section_b = airline#section#create_left(['ffenc','file']) let g:airline_section_c = airline#section#create(['%{getcwd()}']) endfunction - autocmd VimEnter * call AirlineInit() + autocmd User AirlineAfterInit call AirlineInit() < This will create a section with the `mode`, followed by a space, and our `foo` part in section `a`. Section `b` will have two parts with a left-side diff --git a/plugin/airline.vim b/plugin/airline.vim index 3b1a7430..98400529 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -6,36 +6,30 @@ if &cp || v:version < 702 || (exists('g:loaded_airline') && g:loaded_airline) endif let g:loaded_airline = 1 -autocmd VimEnter * call airline#deprecation#check() - -let s:airline_initialized = 0 let s:airline_theme_defined = 0 function! s:init() - if !s:airline_initialized - let s:airline_initialized = 1 + call airline#init#bootstrap() + call airline#extensions#load() + call airline#init#sections() - call airline#init#bootstrap() - call airline#extensions#load() - call airline#init#sections() - - let s:airline_theme_defined = exists('g:airline_theme') - if s:airline_theme_defined || !airline#switch_matching_theme() - let g:airline_theme = get(g:, 'airline_theme', 'dark') - call airline#switch_theme(g:airline_theme) - endif + let s:airline_theme_defined = exists('g:airline_theme') + if s:airline_theme_defined || !airline#switch_matching_theme() + let g:airline_theme = get(g:, 'airline_theme', 'dark') + call airline#switch_theme(g:airline_theme) endif + + silent doautocmd User AirlineAfterInit + call s:airline_toggle() endfunction function! s:on_window_changed() if pumvisible() return endif - call init() call airline#update_statusline() endfunction function! s:on_colorscheme_changed() - call init() if !s:airline_theme_defined if airline#switch_matching_theme() return @@ -81,11 +75,8 @@ function! s:airline_toggle() \ | call airline#load_theme() augroup END + call on_window_changed() silent doautocmd User AirlineToggledOn - - if s:airline_initialized - call on_window_changed() - endif endif endfunction @@ -93,6 +84,7 @@ function! s:get_airline_themes(a, l, p) let files = split(globpath(&rtp, 'autoload/airline/themes/'.a:a.'*'), "\n") return map(files, 'fnamemodify(v:val, ":t:r")') endfunction + function! s:airline_theme(...) if a:0 call airline#switch_theme(a:1) @@ -100,10 +92,12 @@ function! s:airline_theme(...) echo g:airline_theme endif endfunction + command! -nargs=? -complete=customlist,get_airline_themes AirlineTheme call airline_theme() command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle() command! AirlineToggle call airline_toggle() command! AirlineRefresh call airline#load_theme() | call airline#update_statusline() -call airline_toggle() +autocmd VimEnter * call airline#deprecation#check() +autocmd VimEnter * call s:init()