clean up initialization code
This commit is contained in:
parent
5b55dd94f4
commit
59752b2659
|
@ -14,16 +14,17 @@ CONTENTS *airline-contents*
|
||||||
03. Name ................................................. |airline-name|
|
03. Name ................................................. |airline-name|
|
||||||
04. Configuration ............................... |airline-configuration|
|
04. Configuration ............................... |airline-configuration|
|
||||||
05. Commands ......................................... |airline-commands|
|
05. Commands ......................................... |airline-commands|
|
||||||
06. Customization ............................... |airline-customization|
|
06. Autocommands ................................. |airline-autocommands|
|
||||||
07. Extensions ..................................... |airline-extensions|
|
07. Customization ............................... |airline-customization|
|
||||||
08. Advanced Customization ............. |airline-advanced-customization|
|
08. Extensions ..................................... |airline-extensions|
|
||||||
09. Funcrefs ......................................... |airline-funcrefs|
|
09. Advanced Customization ............. |airline-advanced-customization|
|
||||||
10. Pipeline ......................................... |airline-pipeline|
|
10. Funcrefs ......................................... |airline-funcrefs|
|
||||||
11. Writing Extensions ..................... |airline-writing-extensions|
|
11. Pipeline ......................................... |airline-pipeline|
|
||||||
12. Writing Themes ..................................... |airline-themes|
|
12. Writing Extensions ..................... |airline-writing-extensions|
|
||||||
13. Troubleshooting ........................... |airline-troubleshooting|
|
13. Writing Themes ..................................... |airline-themes|
|
||||||
14. Contributions ............................... |airline-contributions|
|
14. Troubleshooting ........................... |airline-troubleshooting|
|
||||||
15. License ........................................... |airline-license|
|
15. Contributions ............................... |airline-contributions|
|
||||||
|
16. License ........................................... |airline-license|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
INTRODUCTION *airline-intro*
|
INTRODUCTION *airline-intro*
|
||||||
|
@ -146,6 +147,17 @@ COMMANDS *airline-commands*
|
||||||
:AirlineRefresh *:AirlineRefresh*
|
:AirlineRefresh *:AirlineRefresh*
|
||||||
Refreshes all highlight groups and redraws the statusline.
|
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*
|
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_b = airline#section#create_left(['ffenc','file'])
|
||||||
let g:airline_section_c = airline#section#create(['%{getcwd()}'])
|
let g:airline_section_c = airline#section#create(['%{getcwd()}'])
|
||||||
endfunction
|
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`
|
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
|
part in section `a`. Section `b` will have two parts with a left-side
|
||||||
|
|
|
@ -6,36 +6,30 @@ if &cp || v:version < 702 || (exists('g:loaded_airline') && g:loaded_airline)
|
||||||
endif
|
endif
|
||||||
let g:loaded_airline = 1
|
let g:loaded_airline = 1
|
||||||
|
|
||||||
autocmd VimEnter * call airline#deprecation#check()
|
|
||||||
|
|
||||||
let s:airline_initialized = 0
|
|
||||||
let s:airline_theme_defined = 0
|
let s:airline_theme_defined = 0
|
||||||
function! s:init()
|
function! s:init()
|
||||||
if !s:airline_initialized
|
call airline#init#bootstrap()
|
||||||
let s:airline_initialized = 1
|
call airline#extensions#load()
|
||||||
|
call airline#init#sections()
|
||||||
|
|
||||||
call airline#init#bootstrap()
|
let s:airline_theme_defined = exists('g:airline_theme')
|
||||||
call airline#extensions#load()
|
if s:airline_theme_defined || !airline#switch_matching_theme()
|
||||||
call airline#init#sections()
|
let g:airline_theme = get(g:, 'airline_theme', 'dark')
|
||||||
|
call airline#switch_theme(g:airline_theme)
|
||||||
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
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
silent doautocmd User AirlineAfterInit
|
||||||
|
call s:airline_toggle()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:on_window_changed()
|
function! s:on_window_changed()
|
||||||
if pumvisible()
|
if pumvisible()
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
call <sid>init()
|
|
||||||
call airline#update_statusline()
|
call airline#update_statusline()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:on_colorscheme_changed()
|
function! s:on_colorscheme_changed()
|
||||||
call <sid>init()
|
|
||||||
if !s:airline_theme_defined
|
if !s:airline_theme_defined
|
||||||
if airline#switch_matching_theme()
|
if airline#switch_matching_theme()
|
||||||
return
|
return
|
||||||
|
@ -81,11 +75,8 @@ function! s:airline_toggle()
|
||||||
\ | call airline#load_theme()
|
\ | call airline#load_theme()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
call <sid>on_window_changed()
|
||||||
silent doautocmd User AirlineToggledOn
|
silent doautocmd User AirlineToggledOn
|
||||||
|
|
||||||
if s:airline_initialized
|
|
||||||
call <sid>on_window_changed()
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -93,6 +84,7 @@ function! s:get_airline_themes(a, l, p)
|
||||||
let files = split(globpath(&rtp, 'autoload/airline/themes/'.a:a.'*'), "\n")
|
let files = split(globpath(&rtp, 'autoload/airline/themes/'.a:a.'*'), "\n")
|
||||||
return map(files, 'fnamemodify(v:val, ":t:r")')
|
return map(files, 'fnamemodify(v:val, ":t:r")')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:airline_theme(...)
|
function! s:airline_theme(...)
|
||||||
if a:0
|
if a:0
|
||||||
call airline#switch_theme(a:1)
|
call airline#switch_theme(a:1)
|
||||||
|
@ -100,10 +92,12 @@ function! s:airline_theme(...)
|
||||||
echo g:airline_theme
|
echo g:airline_theme
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
command! -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>)
|
command! -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>)
|
||||||
command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle()
|
command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle()
|
||||||
command! AirlineToggle call <sid>airline_toggle()
|
command! AirlineToggle call <sid>airline_toggle()
|
||||||
command! AirlineRefresh call airline#load_theme() | call airline#update_statusline()
|
command! AirlineRefresh call airline#load_theme() | call airline#update_statusline()
|
||||||
|
|
||||||
call <sid>airline_toggle()
|
autocmd VimEnter * call airline#deprecation#check()
|
||||||
|
autocmd VimEnter * call s:init()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue