improve whitespace detection; add support for mixed indents
This commit is contained in:
parent
f86eafb674
commit
7fb9bcf2c9
@ -2,10 +2,35 @@
|
||||
" vim: ts=2 sts=2 sw=2 fdm=indent
|
||||
|
||||
function! airline#extensions#whitespace#check()
|
||||
let w:airline_section_warning = '%{get(w:, "airline_active", 0) && search(" $", "nw")'
|
||||
\ .'? " ".g:airline_whitespace_symbol." " : ""}'
|
||||
if line('$') > g:airline_whitespace_max_lines
|
||||
return ''
|
||||
endif
|
||||
|
||||
let trailing = search(' $', 'nw') != 0
|
||||
let mixed = search('^ ', 'nw') != 0 && search('^\t', 'nw') != 0
|
||||
|
||||
if trailing || mixed
|
||||
let text = " ".g:airline_whitespace_symbol." "
|
||||
if g:airline_detect_whitespace == 1
|
||||
if trailing
|
||||
let text .= 'trailing '
|
||||
endif
|
||||
if mixed
|
||||
let text .= 'mixed-indent '
|
||||
endif
|
||||
endif
|
||||
return text
|
||||
endif
|
||||
return ''
|
||||
endfunction!
|
||||
|
||||
function! airline#extensions#whitespace#apply()
|
||||
if exists('w:airline_active') && w:airline_active
|
||||
let w:airline_section_warning = '%{airline#extensions#whitespace#check()}'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#whitespace#init(ext)
|
||||
call a:ext.add_statusline_funcref(function('airline#extensions#whitespace#check'))
|
||||
call a:ext.add_statusline_funcref(function('airline#extensions#whitespace#apply'))
|
||||
endfunction
|
||||
|
||||
|
@ -73,6 +73,13 @@ values):
|
||||
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
|
||||
<
|
||||
|
||||
* change the default theme
|
||||
>
|
||||
let g:airline_theme='dark'
|
||||
@ -132,6 +139,7 @@ separators, as well as the powerline font glyths.
|
||||
let g:airline_paste_symbol = 'ρ'
|
||||
let g:airline_paste_symbol = 'Þ'
|
||||
let g:airline_paste_symbol = '∥'
|
||||
let g:airline_whitespace_symbol = 'Ξ'
|
||||
|
||||
" powerline symbols
|
||||
let g:airline_left_sep = ''
|
||||
@ -157,13 +165,14 @@ with the usual statusline syntax.
|
||||
|
||||
>
|
||||
" here are the the default values
|
||||
let g:airline_section_a (the mode/paste indicator)
|
||||
let g:airline_section_b (the fugitive/lawrencium branch indicator)
|
||||
let g:airline_section_c (bufferline or filename)
|
||||
let g:airline_section_gutter (syntastic, readonly flag)
|
||||
let g:airline_section_x (tagbar, filetype)
|
||||
let g:airline_section_y (fileencoding, fileformat)
|
||||
let g:airline_section_z (percentage, line number, column number)
|
||||
let g:airline_section_a (the mode/paste indicator)
|
||||
let g:airline_section_b (the fugitive/lawrencium branch indicator)
|
||||
let g:airline_section_c (bufferline or filename)
|
||||
let g:airline_section_gutter (syntastic, readonly flag)
|
||||
let g:airline_section_x (tagbar, filetype)
|
||||
let g:airline_section_y (fileencoding, fileformat)
|
||||
let g:airline_section_z (percentage, line number, column number)
|
||||
let g:airline_section_warning (special section that only appears sometimes)
|
||||
|
||||
" here is an example of how you could replace the branch indicator with
|
||||
" the current working directory, followed by the filename.
|
||||
|
@ -29,6 +29,7 @@ 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_whitespace_symbol', '✹')
|
||||
call s:check_defined('g:airline_whitespace_max_lines', 3000)
|
||||
call s:check_defined('g:airline_branch_prefix', exists('g:airline_powerline_fonts')?' ':'')
|
||||
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')?' ':':')
|
||||
|
Loading…
Reference in New Issue
Block a user