mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-22 08:59:14 +08:00
add whitespace toggle command
This commit is contained in:
parent
57955b3b86
commit
4485b03e51
|
@ -137,7 +137,7 @@ function! airline#extensions#load()
|
|||
endif
|
||||
|
||||
if g:airline_detect_whitespace
|
||||
call airline#extensions#whitespace#init(s:ext)
|
||||
call airline#extensions#whitespace#init()
|
||||
endif
|
||||
|
||||
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
|
||||
|
||||
function! airline#extensions#whitespace#check()
|
||||
if &readonly
|
||||
if &readonly || !g:airline_detect_whitespace
|
||||
return ''
|
||||
endif
|
||||
|
||||
|
@ -37,8 +37,21 @@ function! airline#extensions#whitespace#apply()
|
|||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#whitespace#init(ext)
|
||||
call a:ext.add_statusline_funcref(function('airline#extensions#whitespace#apply'))
|
||||
function! airline#extensions#whitespace#toggle()
|
||||
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
|
||||
autocmd!
|
||||
|
|
|
@ -120,6 +120,9 @@ COMMANDS *airline-commands*
|
|||
:AirlineTheme {theme-name} *:AirlineTheme*
|
||||
Displays or changes the current theme.
|
||||
|
||||
:AirlineToggleWhitespace *:AirlineToggleWhitespace*
|
||||
Toggles whitespace detection.
|
||||
|
||||
==============================================================================
|
||||
CUSTOMIZATION *airline-customization*
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ function! s: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()
|
||||
|
||||
augroup airline
|
||||
autocmd!
|
||||
|
|
Loading…
Reference in New Issue
Block a user