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
|
set guioptions-=e
|
||||||
endif
|
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
|
if s:buf_min_count <= 0 && s:tab_min_count <= 1
|
||||||
set showtabline=2
|
set showtabline=2
|
||||||
else
|
else
|
||||||
if s:show_buffers == 1
|
augroup airline_tabline
|
||||||
autocmd CursorMoved * call <sid>on_cursormove(s:buf_min_count, len(s:get_buffer_list()))
|
autocmd!
|
||||||
else
|
if s:show_buffers == 1
|
||||||
autocmd TabEnter * call <sid>on_cursormove(s:tab_min_count, tabpagenr('$'))
|
autocmd CursorMoved * call <sid>on_cursormove(s:buf_min_count, len(s:get_buffer_list()))
|
||||||
endif
|
else
|
||||||
|
autocmd TabEnter * call <sid>on_cursormove(s:tab_min_count, tabpagenr('$'))
|
||||||
|
endif
|
||||||
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call a:ext.add_theme_func('airline#extensions#tabline#load_theme')
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#tabline#load_theme(palette)
|
function! airline#extensions#tabline#load_theme(palette)
|
||||||
|
@ -58,10 +58,12 @@ function! s:airline_toggle()
|
|||||||
augroup! airline
|
augroup! airline
|
||||||
|
|
||||||
if exists("s:stl")
|
if exists("s:stl")
|
||||||
let [ &stl, &tal, &stal ] = [ s:stl, s:tal, s:stal ]
|
let &stl = s:stl
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
silent doautocmd User AirlineToggledOff
|
||||||
else
|
else
|
||||||
let [ s:stl, s:tal, s:stal ] = [ &stl, &tal, &stal ]
|
let s:stl = &statusline
|
||||||
augroup airline
|
augroup airline
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
@ -78,6 +80,9 @@ function! s:airline_toggle()
|
|||||||
\ exec 'source '.split(globpath(&rtp, 'autoload/airline/themes/'.g:airline_theme.'.vim', 1), "\n")[0]
|
\ exec 'source '.split(globpath(&rtp, 'autoload/airline/themes/'.g:airline_theme.'.vim', 1), "\n")[0]
|
||||||
\ | call airline#load_theme()
|
\ | call airline#load_theme()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
silent doautocmd User AirlineToggledOn
|
||||||
|
|
||||||
if s:airline_initialized
|
if s:airline_initialized
|
||||||
call <sid>on_window_changed()
|
call <sid>on_window_changed()
|
||||||
endif
|
endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user