fix and improve airline toggling functionality.
This commit is contained in:
parent
778c0f59ca
commit
592cc412cf
|
@ -27,19 +27,36 @@ function! airline#extensions#tabline#init(ext)
|
|||
set guioptions-=e
|
||||
endif
|
||||
|
||||
set tabline=%!airline#extensions#tabline#get()
|
||||
autocmd User AirlineToggledOn call s:toggle_on()
|
||||
autocmd User AirlineToggledOff call s:toggle_off()
|
||||
|
||||
call s:toggle_on()
|
||||
call a:ext.add_theme_func('airline#extensions#tabline#load_theme')
|
||||
endfunction
|
||||
|
||||
function! s:toggle_off()
|
||||
if exists('s:original_tabline')
|
||||
let &tabline = s:original_tabline
|
||||
let &showtabline = s:original_showtabline
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:toggle_on()
|
||||
let [ s:original_tabline, s:original_showtabline ] = [ &tabline, &showtabline ]
|
||||
|
||||
set tabline=%!airline#extensions#tabline#get()
|
||||
if s:buf_min_count <= 0 && s:tab_min_count <= 1
|
||||
set showtabline=2
|
||||
else
|
||||
if s:show_buffers == 1
|
||||
autocmd CursorMoved * call <sid>on_cursormove(s:buf_min_count, len(s:get_buffer_list()))
|
||||
else
|
||||
autocmd TabEnter * call <sid>on_cursormove(s:tab_min_count, tabpagenr('$'))
|
||||
endif
|
||||
augroup airline_tabline
|
||||
autocmd!
|
||||
if s:show_buffers == 1
|
||||
autocmd CursorMoved * call <sid>on_cursormove(s:buf_min_count, len(s:get_buffer_list()))
|
||||
else
|
||||
autocmd TabEnter * call <sid>on_cursormove(s:tab_min_count, tabpagenr('$'))
|
||||
endif
|
||||
augroup END
|
||||
endif
|
||||
|
||||
call a:ext.add_theme_func('airline#extensions#tabline#load_theme')
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#tabline#load_theme(palette)
|
||||
|
|
|
@ -58,10 +58,12 @@ function! s:airline_toggle()
|
|||
augroup! airline
|
||||
|
||||
if exists("s:stl")
|
||||
let [ &stl, &tal, &stal ] = [ s:stl, s:tal, s:stal ]
|
||||
let &stl = s:stl
|
||||
endif
|
||||
|
||||
silent doautocmd User AirlineToggledOff
|
||||
else
|
||||
let [ s:stl, s:tal, s:stal ] = [ &stl, &tal, &stal ]
|
||||
let s:stl = &statusline
|
||||
augroup airline
|
||||
autocmd!
|
||||
|
||||
|
@ -78,6 +80,9 @@ function! s:airline_toggle()
|
|||
\ exec 'source '.split(globpath(&rtp, 'autoload/airline/themes/'.g:airline_theme.'.vim', 1), "\n")[0]
|
||||
\ | call airline#load_theme()
|
||||
augroup END
|
||||
|
||||
silent doautocmd User AirlineToggledOn
|
||||
|
||||
if s:airline_initialized
|
||||
call <sid>on_window_changed()
|
||||
endif
|
||||
|
|
Loading…
Reference in New Issue