From 8ec527465dc8ecdd72c369ec274383e949d40122 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Wed, 14 Aug 2013 23:56:55 +0200 Subject: [PATCH] added airlinetoggle function --- doc/airline.txt | 3 +++ plugin/airline.vim | 31 +++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/doc/airline.txt b/doc/airline.txt index cce5592..8f61721 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -144,6 +144,9 @@ COMMANDS *airline-commands* :AirlineToggleWhitespace *:AirlineToggleWhitespace* Toggles whitespace detection. +:AirlineToggle *:AirlineToggle* + Toggle this plugin (e.g. the nice statusline) + ============================================================================== CUSTOMIZATION *airline-customization* diff --git a/plugin/airline.vim b/plugin/airline.vim index 3c74f5f..377dbf1 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -57,6 +57,7 @@ call s:check_defined('g:airline_mode_map', { \ '' : 'S-BLOCK', \ }) + call s:check_defined('g:airline_section_a', '%{get(w:, "airline_current_mode", "")}') call s:check_defined('g:airline_section_b', '%{get(w:, "airline_current_branch", "")}') call s:check_defined('g:airline_section_c', '%f%m') @@ -76,6 +77,28 @@ function! s:on_window_changed() call airline#update_statusline() endfunction +function! s:airline_toggle() + if exists("#airline") + augroup airline + au! + augroup END + augroup! airline + if exists("s:stl") + let &stl = s:stl + endif + else + let s:stl = &stl + augroup airline + autocmd! + autocmd ColorScheme * call airline#reload_highlight() + autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost * + \ call on_window_changed() + augroup END + " update statusline now + call on_window_changed() + endif +endfunction + 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")') @@ -89,10 +112,6 @@ function! s:airline_theme(...) endfunction command! -nargs=? -complete=customlist,get_airline_themes AirlineTheme call airline_theme() command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle() +command! AirlineToggle call airline_toggle() -augroup airline - autocmd! - autocmd ColorScheme * call airline#reload_highlight() - autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost * - \ call on_window_changed() -augroup END +call airline_toggle()