mirror of
https://github.com/vim-airline/vim-airline-themes.git
synced 2025-03-03 14:46:25 +08:00
add whitespace toggle command
This commit is contained in:
parent
57955b3b86
commit
4485b03e51
@ -137,7 +137,7 @@ function! airline#extensions#load()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if g:airline_detect_whitespace
|
if g:airline_detect_whitespace
|
||||||
call airline#extensions#whitespace#init(s:ext)
|
call airline#extensions#whitespace#init()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0)
|
call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
" http://got-ravings.blogspot.com/2008/10/vim-pr0n-statusline-whitespace-flags.html
|
" http://got-ravings.blogspot.com/2008/10/vim-pr0n-statusline-whitespace-flags.html
|
||||||
|
|
||||||
function! airline#extensions#whitespace#check()
|
function! airline#extensions#whitespace#check()
|
||||||
if &readonly
|
if &readonly || !g:airline_detect_whitespace
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -37,8 +37,21 @@ function! airline#extensions#whitespace#apply()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#whitespace#init(ext)
|
function! airline#extensions#whitespace#toggle()
|
||||||
call a:ext.add_statusline_funcref(function('airline#extensions#whitespace#apply'))
|
let g:airline_detect_whitespace = !g:airline_detect_whitespace
|
||||||
|
if g:airline_detect_whitespace
|
||||||
|
call airline#extensions#whitespace#init()
|
||||||
|
else
|
||||||
|
autocmd! airline_whitespace CursorHold,BufWritePost
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
let s:initialized = 0
|
||||||
|
function! airline#extensions#whitespace#init()
|
||||||
|
if !s:initialized
|
||||||
|
let s:initialized = 1
|
||||||
|
call add(g:airline_statusline_funcrefs, function('airline#extensions#whitespace#apply'))
|
||||||
|
endif
|
||||||
|
|
||||||
augroup airline_whitespace
|
augroup airline_whitespace
|
||||||
autocmd!
|
autocmd!
|
||||||
|
@ -120,6 +120,9 @@ COMMANDS *airline-commands*
|
|||||||
:AirlineTheme {theme-name} *:AirlineTheme*
|
:AirlineTheme {theme-name} *:AirlineTheme*
|
||||||
Displays or changes the current theme.
|
Displays or changes the current theme.
|
||||||
|
|
||||||
|
:AirlineToggleWhitespace *:AirlineToggleWhitespace*
|
||||||
|
Toggles whitespace detection.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
CUSTOMIZATION *airline-customization*
|
CUSTOMIZATION *airline-customization*
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ function! s: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()
|
||||||
|
|
||||||
augroup airline
|
augroup airline
|
||||||
autocmd!
|
autocmd!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user