mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-26 23:44:30 +02:00
add support for configurable whitespace checking algorithms and default it to the simplest one. resolves #484
This commit is contained in:
parent
abee990d30
commit
e49eac95a3
@ -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: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: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:max_lines = get(g:, 'airline#extensions#whitespace#max_lines', 20000)
|
||||||
|
|
||||||
let s:enabled = 1
|
let s:enabled = 1
|
||||||
|
|
||||||
|
function! s:check_mixed_indent()
|
||||||
|
if s:indent_algo == 0
|
||||||
|
return search('\v(^\t+ +)|(^ +\t+)', 'nw')
|
||||||
|
else
|
||||||
|
" [<tab>]<space><tab>
|
||||||
|
" spaces before or between tabs are not allowed
|
||||||
|
let t_s_t = '(^\t* +\t\s*\S)'
|
||||||
|
" <tab>(<space> 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()
|
function! airline#extensions#whitespace#check()
|
||||||
if &readonly || !&modifiable || !s:enabled || line('$') > s:max_lines
|
if &readonly || !&modifiable || !s:enabled || line('$') > s:max_lines
|
||||||
return ''
|
return ''
|
||||||
@ -36,13 +51,7 @@ function! airline#extensions#whitespace#check()
|
|||||||
|
|
||||||
let mixed = 0
|
let mixed = 0
|
||||||
if index(checks, 'indent') > -1
|
if index(checks, 'indent') > -1
|
||||||
" [<tab>]<space><tab>
|
let mixed = s:check_mixed_indent()
|
||||||
" Spaces before or between tabs are not allowed
|
|
||||||
let t_s_t = '(^\t* +\t\s*\S)'
|
|
||||||
" <tab>(<space> 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')
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if trailing != 0 || mixed != 0
|
if trailing != 0 || mixed != 0
|
||||||
|
@ -289,7 +289,7 @@ tagbar <https://github.com/majutsushi/tagbar>
|
|||||||
let g:airline#extensions#tagbar#enabled = 1
|
let g:airline#extensions#tagbar#enabled = 1
|
||||||
<
|
<
|
||||||
* change how tags are displayed (:help tagbar-statusline) >
|
* 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 = 'f'
|
||||||
let g:airline#extensions#tagbar#flags = 's'
|
let g:airline#extensions#tagbar#flags = 's'
|
||||||
let g:airline#extensions#tagbar#flags = 'p'
|
let g:airline#extensions#tagbar#flags = 'p'
|
||||||
@ -349,6 +349,14 @@ eclim <https://eclim.org>
|
|||||||
* enable/disable detection of whitespace errors. >
|
* enable/disable detection of whitespace errors. >
|
||||||
let g:airline#extensions#whitespace#enabled = 1
|
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. >
|
* customize the whitespace symbol. >
|
||||||
let g:airline#extensions#whitespace#symbol = '!'
|
let g:airline#extensions#whitespace#symbol = '!'
|
||||||
<
|
<
|
||||||
|
Loading…
x
Reference in New Issue
Block a user