diff --git a/autoload/airline/extensions/whitespace.vim b/autoload/airline/extensions/whitespace.vim index f987ec08..60fd3d3d 100644 --- a/autoload/airline/extensions/whitespace.vim +++ b/autoload/airline/extensions/whitespace.vim @@ -15,11 +15,26 @@ let s:default_checks = ['indent', 'trailing'] let s:trailing_format = get(g:, 'airline#extensions#whitespace#trailing_format', 'trailing[%s]') let s:mixed_indent_format = get(g:, 'airline#extensions#whitespace#mixed_indent_format', 'mixed-indent[%s]') +let s:indent_algo = get(g:, 'airline#extensions#whitespace#mixed_indent_algo', 0) let s:max_lines = get(g:, 'airline#extensions#whitespace#max_lines', 20000) let s:enabled = 1 +function! s:check_mixed_indent() + if s:indent_algo == 0 + return search('\v(^\t+ +)|(^ +\t+)', 'nw') + else + " [] + " spaces before or between tabs are not allowed + let t_s_t = '(^\t* +\t\s*\S)' + " ( x count) + " count of spaces at the end of tabs should be less then tabstop value + let t_l_s = '(^\t+ {' . &ts . ',}' . '\S)' + return search('\v' . t_s_t . '|' . t_l_s, 'nw') + endif +endfunction + function! airline#extensions#whitespace#check() if &readonly || !&modifiable || !s:enabled || line('$') > s:max_lines return '' @@ -36,13 +51,7 @@ function! airline#extensions#whitespace#check() let mixed = 0 if index(checks, 'indent') > -1 - " [] - " Spaces before or between tabs are not allowed - let t_s_t = '(^\t* +\t\s*\S)' - " ( x count) - " Count of spaces at the end of tabs should be less then tabstop value - let t_l_s = '(^\t+ {' . &ts . ',}' . '\S)' - let mixed = search('\v' . t_s_t . '|' . t_l_s, 'nw') + let mixed = s:check_mixed_indent() endif if trailing != 0 || mixed != 0 diff --git a/doc/airline.txt b/doc/airline.txt index 5a7df84d..81342393 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -289,7 +289,7 @@ tagbar let g:airline#extensions#tagbar#enabled = 1 < * change how tags are displayed (:help tagbar-statusline) > - let g:airline#extensions#tagbar#flags = '' "default + let g:airline#extensions#tagbar#flags = '' (default) let g:airline#extensions#tagbar#flags = 'f' let g:airline#extensions#tagbar#flags = 's' let g:airline#extensions#tagbar#flags = 'p' @@ -349,6 +349,14 @@ eclim * enable/disable detection of whitespace errors. > let g:airline#extensions#whitespace#enabled = 1 < +* customize the type of mixed indent checking to perform. > + " must be all spaces or all tabs before the first non-whitespace character + let g:airline#extensions#whitespace#mixed_indent_algo = 0 (default) + + " certain number of spaces are allowed after tabs, but not in between + " this algorithm works well for /** */ style comments in a tab-indented file + let g:airline#extensions#whitespace#mixed_indent_algo = 1 +< * customize the whitespace symbol. > let g:airline#extensions#whitespace#symbol = '!' <