mirror of
https://github.com/vim-airline/vim-airline.git
synced 2026-01-01 00:53:21 +08:00
clean up initialization code
This commit is contained in:
@@ -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 <sid>init()
|
||||
call airline#update_statusline()
|
||||
endfunction
|
||||
|
||||
function! s:on_colorscheme_changed()
|
||||
call <sid>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 <sid>on_window_changed()
|
||||
silent doautocmd User AirlineToggledOn
|
||||
|
||||
if s:airline_initialized
|
||||
call <sid>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,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>)
|
||||
command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle()
|
||||
command! AirlineToggle call <sid>airline_toggle()
|
||||
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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user