mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-27 10:49:51 +08:00
whitespace: move s:variables around
Will make sure, that even after setting the whitespace extension variables, they are taken correctly into account.
This commit is contained in:
parent
a914cfb754
commit
a10d321809
|
@ -9,18 +9,12 @@ 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: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']
|
||||||
|
|
||||||
let s:trailing_format = get(g:, 'airline#extensions#whitespace#trailing_format', '[%s]trailing')
|
|
||||||
let s:mixed_indent_format = get(g:, 'airline#extensions#whitespace#mixed_indent_format', '[%s]mixed-indent')
|
|
||||||
let s:long_format = get(g:, 'airline#extensions#whitespace#long_format', '[%s]long')
|
|
||||||
let s:mixed_indent_file_format = get(g:, 'airline#extensions#whitespace#mixed_indent_file_format', '[%s]mix-indent-file')
|
|
||||||
let s:indent_algo = get(g:, 'airline#extensions#whitespace#mixed_indent_algo', 0)
|
|
||||||
let s:skip_check_ft = {'make': ['indent', 'mixed-indent-file'] }
|
|
||||||
let s:max_lines = get(g:, 'airline#extensions#whitespace#max_lines', 20000)
|
|
||||||
let s:enabled = get(g:, 'airline#extensions#whitespace#enabled', 1)
|
let s:enabled = get(g:, 'airline#extensions#whitespace#enabled', 1)
|
||||||
let s:c_like_langs = get(g:, 'airline#extensions#c_like_langs', [ 'c', 'cpp', 'cuda', 'go', 'javascript', 'ld', 'php' ])
|
let s:skip_check_ft = {'make': ['indent', 'mixed-indent-file'] }
|
||||||
|
|
||||||
function! s:check_mixed_indent()
|
function! s:check_mixed_indent()
|
||||||
if s:indent_algo == 1
|
let indent_algo = get(g:, 'airline#extensions#whitespace#mixed_indent_algo', 0)
|
||||||
|
if indent_algo == 1
|
||||||
" [<tab>]<space><tab>
|
" [<tab>]<space><tab>
|
||||||
" spaces before or between tabs are not allowed
|
" spaces before or between tabs are not allowed
|
||||||
let t_s_t = '(^\t* +\t\s*\S)'
|
let t_s_t = '(^\t* +\t\s*\S)'
|
||||||
|
@ -28,7 +22,7 @@ function! s:check_mixed_indent()
|
||||||
" count of spaces at the end of tabs should be less than tabstop value
|
" count of spaces at the end of tabs should be less than tabstop value
|
||||||
let t_l_s = '(^\t+ {' . &ts . ',}' . '\S)'
|
let t_l_s = '(^\t+ {' . &ts . ',}' . '\S)'
|
||||||
return search('\v' . t_s_t . '|' . t_l_s, 'nw')
|
return search('\v' . t_s_t . '|' . t_l_s, 'nw')
|
||||||
elseif s:indent_algo == 2
|
elseif indent_algo == 2
|
||||||
return search('\v(^\t* +\t\s*\S)', 'nw')
|
return search('\v(^\t* +\t\s*\S)', 'nw')
|
||||||
else
|
else
|
||||||
return search('\v(^\t+ +)|(^ +\t+)', 'nw')
|
return search('\v(^\t+ +)|(^ +\t+)', 'nw')
|
||||||
|
@ -36,7 +30,9 @@ function! s:check_mixed_indent()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:check_mixed_indent_file()
|
function! s:check_mixed_indent_file()
|
||||||
if index(s:c_like_langs, &ft) > -1
|
let c_like_langs = get(g:, 'airline#extensions#c_like_langs',
|
||||||
|
\ [ 'c', 'cpp', 'cuda', 'go', 'javascript', 'ld', 'php' ])
|
||||||
|
if index(c_like_langs, &ft) > -1
|
||||||
" for C-like languages: allow /** */ comment style with one space before the '*'
|
" for C-like languages: allow /** */ comment style with one space before the '*'
|
||||||
let head_spc = '\v(^ +\*@!)'
|
let head_spc = '\v(^ +\*@!)'
|
||||||
else
|
else
|
||||||
|
@ -52,7 +48,8 @@ function! s:check_mixed_indent_file()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#whitespace#check()
|
function! airline#extensions#whitespace#check()
|
||||||
if &readonly || !&modifiable || !s:enabled || line('$') > s:max_lines
|
let max_lines = get(g:, 'airline#extensions#whitespace#max_lines', 20000)
|
||||||
|
if &readonly || !&modifiable || !s:enabled || line('$') > max_lines
|
||||||
\ || get(b:, 'airline_whitespace_disabled', 0)
|
\ || get(b:, 'airline_whitespace_disabled', 0)
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
|
@ -100,16 +97,20 @@ function! airline#extensions#whitespace#check()
|
||||||
|
|
||||||
if s:show_message
|
if s:show_message
|
||||||
if trailing != 0
|
if trailing != 0
|
||||||
let b:airline_whitespace_check .= space.printf(s:trailing_format, trailing)
|
let trailing_fmt = get(g:, 'airline#extensions#whitespace#trailing_format', '[%s]trailing')
|
||||||
|
let b:airline_whitespace_check .= space.printf(trailing_fm, trailing)
|
||||||
endif
|
endif
|
||||||
if mixed != 0
|
if mixed != 0
|
||||||
let b:airline_whitespace_check .= space.printf(s:mixed_indent_format, mixed)
|
let mixed_indent_fmt = get(g:, 'airline#extensions#whitespace#mixed_indent_format', '[%s]mixed-indent')
|
||||||
|
let b:airline_whitespace_check .= space.printf(mixed_indent_fmt, mixed)
|
||||||
endif
|
endif
|
||||||
if long != 0
|
if long != 0
|
||||||
let b:airline_whitespace_check .= space.printf(s:long_format, long)
|
let long_fmt = get(g:, 'airline#extensions#whitespace#long_format', '[%s]long')
|
||||||
|
let b:airline_whitespace_check .= space.printf(long_fmt, long)
|
||||||
endif
|
endif
|
||||||
if !empty(mixed_file)
|
if !empty(mixed_file)
|
||||||
let b:airline_whitespace_check .= space.printf(s:mixed_indent_file_format, mixed_file)
|
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
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user