From f773325fa454419cadd36f1dc53cdaf8dca8754c Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Mon, 19 Aug 2013 18:19:26 +0000 Subject: [PATCH] allow specific whitespace checks to be enabled/disabled. --- autoload/airline/extensions/whitespace.vim | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/autoload/airline/extensions/whitespace.vim b/autoload/airline/extensions/whitespace.vim index 7f7ec693..db5e8791 100644 --- a/autoload/airline/extensions/whitespace.vim +++ b/autoload/airline/extensions/whitespace.vim @@ -6,6 +6,8 @@ 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 @@ -16,9 +18,17 @@ function! airline#extensions#whitespace#check() if !exists('b:airline_whitespace_check') let b:airline_whitespace_check = '' - let trailing = search(' $', 'nw') - let indents = [search('^ ', 'nb'), search('^ ', 'n'), search('^\t', 'nb'), search('^\t', 'n')] - let mixed = indents[0] != 0 && indents[1] != 0 && indents[2] != 0 && indents[3] != 0 + + let trailing = 0 + if index(s:checks, 'trailing') > -1 + let trailing = search(' $', 'nw') + endif + + let mixed = 0 + if index(s:checks, 'indent') > -1 + let indents = [search('^ ', 'nb'), search('^ ', 'n'), search('^\t', 'nb'), search('^\t', 'n')] + let mixed = indents[0] != 0 && indents[1] != 0 && indents[2] != 0 && indents[3] != 0 + endif if trailing != 0 || mixed let b:airline_whitespace_check = s:symbol." "