diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index f1ec5a6..454f68a 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -163,7 +163,7 @@ function! airline#extensions#load() call airline#extensions#bufferline#init(s:ext) endif - if g:airline_detect_whitespace + if (get(g:, 'airline#extensions#whitespace#enabled', 1) && get(g:, 'airline_detect_whitespace', 1)) call airline#extensions#whitespace#init() endif diff --git a/autoload/airline/extensions/whitespace.vim b/autoload/airline/extensions/whitespace.vim index db5e879..0e21a42 100644 --- a/autoload/airline/extensions/whitespace.vim +++ b/autoload/airline/extensions/whitespace.vim @@ -3,16 +3,23 @@ " http://got-ravings.blogspot.com/2008/10/vim-pr0n-statusline-whitespace-flags.html +" for backwards compatibility +if exists('g:airline_detect_whitespace') + let s:show_message = g:airline_detect_whitespace == 1 +else + let s:show_message = get(g:, 'airline#extensions#whitespace#show_message', 1) +endif + let s:symbol = get(g:, 'airline#extensions#whitespace#symbol', \ get(g:, 'airline_whitespace_symbol', exists('g:airline_powerline_fonts') ? '✹' : '!')) let s:checks = get(g:, 'airline#extensions#whitespace#checks', ['indent', 'trailing']) let s:initialized = 0 -let s:vimrc_detect_whitespace = g:airline_detect_whitespace +let s:enabled = 1 function! airline#extensions#whitespace#check() - if &readonly || g:airline_detect_whitespace <= 0 + if &readonly || !s:enabled return '' endif @@ -32,7 +39,7 @@ function! airline#extensions#whitespace#check() if trailing != 0 || mixed let b:airline_whitespace_check = s:symbol." " - if g:airline_detect_whitespace == 1 + if s:show_message if trailing != 0 let b:airline_whitespace_check .= 'trailing['.trailing.'] ' endif @@ -54,12 +61,12 @@ function! airline#extensions#whitespace#apply() endfunction function! airline#extensions#whitespace#toggle() - if g:airline_detect_whitespace > 0 + if s:enabled autocmd! airline_whitespace CursorHold,BufWritePost - let g:airline_detect_whitespace = 0 + let s:enabled = 0 else call airline#extensions#whitespace#init() - let g:airline_detect_whitespace = s:vimrc_detect_whitespace + let s:enabled = 1 endif endfunction @@ -69,6 +76,7 @@ function! airline#extensions#whitespace#init() call add(g:airline_statusline_funcrefs, function('airline#extensions#whitespace#apply')) endif + unlet! b:airline_whitespace_check augroup airline_whitespace autocmd! autocmd CursorHold,BufWritePost * unlet! b:airline_whitespace_check diff --git a/doc/airline.txt b/doc/airline.txt index 0b54a57..236205a 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -52,11 +52,6 @@ values): * enable iminsert detection > let g:airline_detect_iminsert=1 < -* enable whitespace detection > - let g:airline_detect_whitespace=0 "disabled - let g:airline_detect_whitespace=1 "icon and message (default) - let g:airline_detect_whitespace=2 "icon only -< * determine whether inactive windows should have the left section collapsed to only the filename of that buffer. > let g:airline_inactive_collapse=1 @@ -218,6 +213,19 @@ vim-gitgutter * set hunk count symbols. > let g:airline#extensions#hunks#hunk_symbols = ['+', '~', '-'] < + *airline-whitespace* +* enable/disable detection of whitespace errors. > + let g:airline#extensions#whitespace#enabled = 1 +< +* customize the whitespace symbol. > + let g:airline#extensions#whitespace#symbol = '!' +< +* configure which whitespace checks to enable. > + let g:airline#extensions#whitespace#checks = [ 'indent', 'trailing' ] +< +* configure whether a message should be displayed. > + let g:airline#extensions#whitespace#show_message = 1 +< ============================================================================== FUNCREFS *airline-funcrefs* diff --git a/plugin/airline.vim b/plugin/airline.vim index 3e100cd..0b0bd30 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -19,7 +19,6 @@ call s:check_defined('g:airline_right_alt_sep', exists('g:airline_powerline_font call s:check_defined('g:airline_detect_iminsert', 0) call s:check_defined('g:airline_detect_modified', 1) call s:check_defined('g:airline_detect_paste', 1) -call s:check_defined('g:airline_detect_whitespace', 1) call s:check_defined('g:airline_readonly_symbol', exists('g:airline_powerline_fonts')?'':'RO') call s:check_defined('g:airline_linecolumn_prefix', exists('g:airline_powerline_fonts')?' ':':') call s:check_defined('g:airline_paste_symbol', (exists('g:airline_powerline_fonts') ? ' ' : '').'PASTE')