whitespace: Also check for Git conflict markers
This commit is contained in:
parent
d4f645777e
commit
538326ceac
@ -7,7 +7,7 @@ scriptencoding utf-8
|
||||
|
||||
let s:show_message = get(g:, 'airline#extensions#whitespace#show_message', 1)
|
||||
let s:symbol = get(g:, 'airline#extensions#whitespace#symbol', g:airline_symbols.whitespace)
|
||||
let s:default_checks = ['indent', 'trailing', 'mixed-indent-file']
|
||||
let s:default_checks = ['indent', 'trailing', 'mixed-indent-file', 'conflicts']
|
||||
|
||||
let s:enabled = get(g:, 'airline#extensions#whitespace#enabled', 1)
|
||||
let s:skip_check_ft = {'make': ['indent', 'mixed-indent-file']}
|
||||
@ -47,6 +47,14 @@ function! s:check_mixed_indent_file()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:conflict_marker()
|
||||
" Checks for git conflict markers
|
||||
let annotation = '\%([0-9A-Za-z_.:]\+\)\?'
|
||||
let pattern = '^\%(\%(<\{7} '.annotation. '\)\|\%(=\{7\}\)\|\%(>\{7\} '.annotation.'\)\)$'
|
||||
let result = search(pattern, 'nw')
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#whitespace#check()
|
||||
let max_lines = get(g:, 'airline#extensions#whitespace#max_lines', 20000)
|
||||
if &readonly || !&modifiable || !s:enabled || line('$') > max_lines
|
||||
@ -90,7 +98,12 @@ function! airline#extensions#whitespace#check()
|
||||
let long = search('\%>'.&tw.'v.\+', 'nw')
|
||||
endif
|
||||
|
||||
if trailing != 0 || mixed != 0 || long != 0 || !empty(mixed_file)
|
||||
let conflicts = 0
|
||||
if index(checks, 'conflicts') > -1
|
||||
let conflicts = s:conflict_marker()
|
||||
endif
|
||||
|
||||
if trailing != 0 || mixed != 0 || long != 0 || !empty(mixed_file) || conflicts != 0
|
||||
let b:airline_whitespace_check = s:symbol
|
||||
if strlen(s:symbol) > 0
|
||||
let space = (g:airline_symbols.space)
|
||||
@ -115,6 +128,10 @@ function! airline#extensions#whitespace#check()
|
||||
let mixed_indent_file_fmt = get(g:, 'airline#extensions#whitespace#mixed_indent_file_format', '[%s]mix-indent-file')
|
||||
let b:airline_whitespace_check .= space.printf(mixed_indent_file_fmt, mixed_file)
|
||||
endif
|
||||
if !empty(conflicts)
|
||||
let conflicts_fmt = get(g:, 'airline#extensions#whitespace#conflicts_format', '[%s]conflicts')
|
||||
let b:airline_whitespace_check .= space.printf(conflicts_fmt, conflicts)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
@ -1145,10 +1145,11 @@ virtualenv <https://github.com/jmcantrell/vim-virtualenv>
|
||||
" long: overlong lines
|
||||
" trailing: trailing whitespace
|
||||
" mixed-indent-file: different indentation in different lines
|
||||
let g:airline#extensions#whitespace#checks = [ 'indent', 'trailing', 'long', 'mixed-indent-file' ]
|
||||
" conflicts: checks for conflict markers
|
||||
let g:airline#extensions#whitespace#checks = [ 'indent', 'trailing', 'long', 'mixed-indent-file', 'conflicts' ]
|
||||
|
||||
" this can also be configured for an individual buffer
|
||||
let b:airline_whitespace_checks = [ 'indent', 'trailing', 'long', 'mixed-indent-file' ]
|
||||
let b:airline_whitespace_checks = [ 'indent', 'trailing', 'long', 'mixed-indent-file', 'conflicts ]
|
||||
<
|
||||
* configure the maximum number of lines where whitespace checking is enabled. >
|
||||
let g:airline#extensions#whitespace#max_lines = 20000
|
||||
@ -1161,6 +1162,7 @@ virtualenv <https://github.com/jmcantrell/vim-virtualenv>
|
||||
let g:airline#extensions#whitespace#mixed_indent_format = 'mixed-indent[%s]'
|
||||
let g:airline#extensions#whitespace#long_format = 'long[%s]'
|
||||
let g:airline#extensions#whitespace#mixed_indent_file_format = 'mix-indent-file[%s]'
|
||||
let g:airline#extensions#whitespace#conflicts_format = 'conflicts[%s]'
|
||||
|
||||
* configure custom trailing whitespace regexp rule >
|
||||
let g:airline#extensions#whitespace#trailing_regexp = '\s$'
|
||||
|
Loading…
Reference in New Issue
Block a user