Cleanup.
Adds an option g:syntastic_xhtml_tidy_ignore_errors to xhtml/tidy. Cosmetic code changes.
This commit is contained in:
parent
f76ae1cc0f
commit
408287de6f
@ -6,6 +6,12 @@ let g:loaded_syntastic_util_autoload = 1
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists("g:syntastic_debug")
|
||||
let g:syntastic_debug = 0
|
||||
endif
|
||||
|
||||
let s:deprecationNoticesIssued = []
|
||||
|
||||
function! syntastic#util#DevNull()
|
||||
if has('win32')
|
||||
return 'NUL'
|
||||
@ -23,7 +29,7 @@ endfunction
|
||||
"returns
|
||||
"
|
||||
"{'exe': '/usr/bin/perl', 'args': ['-f', '-bar']}
|
||||
function! syntastic#util#ParseShebang()
|
||||
function! syntastic#util#parseShebang()
|
||||
for lnum in range(1,5)
|
||||
let line = getline(lnum)
|
||||
|
||||
@ -92,16 +98,6 @@ function! syntastic#util#wideMsg(msg)
|
||||
let &showcmd=old_showcmd
|
||||
endfunction
|
||||
|
||||
if !exists("g:syntastic_debug")
|
||||
let g:syntastic_debug = 0
|
||||
endif
|
||||
|
||||
function! syntastic#util#debug(msg)
|
||||
if g:syntastic_debug
|
||||
echomsg "(Syntastic debug) - " . a:msg
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Check whether a buffer is loaded, listed, and not hidden
|
||||
function! syntastic#util#bufIsActive(buffer)
|
||||
" convert to number, or hell breaks loose
|
||||
@ -121,6 +117,18 @@ function! syntastic#util#bufIsActive(buffer)
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" Used to sort error lists
|
||||
function! syntastic#util#compareErrorItems(a, b)
|
||||
if a:a['lnum'] != a:b['lnum']
|
||||
return a:a['lnum'] - a:b['lnum']
|
||||
elseif a:a['type'] !=? a:b['type']
|
||||
" errors take precedence over warnings
|
||||
return a:a['type'] ==? 'e' ? -1 : 1
|
||||
else
|
||||
return a:a['col'] - a:b['col']
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" List of buffers referenced by the location list
|
||||
function! syntastic#util#unique(list)
|
||||
let seen = {}
|
||||
@ -130,7 +138,12 @@ function! syntastic#util#unique(list)
|
||||
return keys(seen)
|
||||
endfunction
|
||||
|
||||
let s:deprecationNoticesIssued = []
|
||||
function! syntastic#util#debug(msg)
|
||||
if g:syntastic_debug
|
||||
echomsg "syntastic: debug: " . a:msg
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! syntastic#util#deprecationWarn(msg)
|
||||
if index(s:deprecationNoticesIssued, a:msg) >= 0
|
||||
return
|
||||
|
@ -47,9 +47,8 @@ function! SyntaxCheckers_cpp_cpplint_GetLocList()
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'subtype': 'Style' })
|
||||
|
||||
" change error types according to the prescribed threshold
|
||||
for n in range(0, len(loclist) - 1)
|
||||
for n in range(len(loclist))
|
||||
let loclist[n]['type'] = loclist[n]['type'] < g:syntastic_cpp_cpplint_thres ? 'W' : 'E'
|
||||
let n -= 1
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
|
@ -44,15 +44,11 @@ function! SyntaxCheckers_css_prettycss_GetLocList()
|
||||
\ '%-G%.%#'
|
||||
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr("")} })
|
||||
for n in range(0, len(loclist) - 1)
|
||||
for n in range(len(loclist))
|
||||
let loclist[n]["text"] .= ')'
|
||||
endfor
|
||||
|
||||
return sort(loclist, 's:CmpLoclist')
|
||||
endfunction
|
||||
|
||||
function! s:CmpLoclist(a, b)
|
||||
return a:a['lnum'] - a:b['lnum']
|
||||
return sort(loclist, 'syntastic#util#compareErrorItems')
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
|
@ -21,21 +21,11 @@ endfunction
|
||||
function! SyntaxCheckers_html_w3_GetLocList()
|
||||
let makeprg2="curl -s -F output=text -F \"uploaded_file=@".expand('%:p').";type=text/html\" http://validator.w3.org/check \\| sed -n -e '/\<em\>Line\.\*/ \{ N; s/\\n//; N; s/\\n//; /msg/p; \}' -e ''/msg_warn/p'' -e ''/msg_info/p'' \\| sed -e 's/[ ]\\+/ /g' -e 's/\<[\^\>]\*\>//g' -e 's/\^[ ]//g'"
|
||||
let errorformat2='Line %l\, Column %c: %m'
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg2, 'errorformat': errorformat2 })
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg2, 'errorformat': errorformat2, 'defaults': {'bufnr': bufnr("")} })
|
||||
|
||||
let n = len(loclist) - 1
|
||||
let bufnum = bufnr("")
|
||||
while n >= 0
|
||||
let i = loclist[n]
|
||||
let i['bufnr'] = bufnum
|
||||
|
||||
if i['lnum'] == 0
|
||||
let i['type'] = 'w'
|
||||
else
|
||||
let i['type'] = 'e'
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
for n in range(len(loclist))
|
||||
let loclist[n]['type'] = loclist[n]['lnum'] ? 'E' : 'W'
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
@ -52,7 +52,7 @@ function! SyntaxCheckers_perl_perl_GetLocList()
|
||||
endfunction
|
||||
|
||||
function! s:ExtraMakeprgArgs()
|
||||
let shebang = syntastic#util#ParseShebang()
|
||||
let shebang = syntastic#util#parseShebang()
|
||||
if index(shebang['args'], '-T') != -1
|
||||
return ' -Tc'
|
||||
endif
|
||||
|
@ -46,11 +46,9 @@ function! SyntaxCheckers_perl_perlcritic_GetLocList()
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'subtype': 'Style' })
|
||||
|
||||
" change error types according to the prescribed threshold
|
||||
let n = len(loclist) - 1
|
||||
while n >= 0
|
||||
for n in range(len(loclist))
|
||||
let loclist[n]['type'] = loclist[n]['type'] < g:syntastic_perl_perlcritic_thres ? 'W' : 'E'
|
||||
let n -= 1
|
||||
endwhile
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
@ -26,17 +26,11 @@ function! SyntaxCheckers_python_pylint_GetLocList()
|
||||
|
||||
let loclist=SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
let n = len(loclist) - 1
|
||||
while n >= 0
|
||||
for n in range(len(loclist))
|
||||
let loclist[n]['type'] = match(['R', 'C', 'W'], loclist[n]['text'][2]) >= 0 ? 'W' : 'E'
|
||||
let n -= 1
|
||||
endwhile
|
||||
endfor
|
||||
|
||||
return sort(loclist, 's:CmpLoclist')
|
||||
endfunction
|
||||
|
||||
function! s:CmpLoclist(a, b)
|
||||
return a:a['lnum'] - a:b['lnum']
|
||||
return sort(loclist, 'syntastic#util#compareErrorItems')
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
|
@ -44,11 +44,8 @@ function! SyntaxCheckers_tex_chktex_GetLocList()
|
||||
let errorformat = '%EError\ %\\d%\\+\ in\ %f\ line\ %l:\ %m,%WWarning\ %\\d%\\+\ in\ %f\ line\ %l:\ %m,' .
|
||||
\ (g:syntastic_tex_chktex_showmsgs ? '%WMessage\ %\\d%\\+\ in\ %f\ line %l:\ %m,' : '') .
|
||||
\ '%+Z%p^,%-G%.%#'
|
||||
return sort(SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'subtype': 'Style' }), 's:CmpLoclist')
|
||||
endfunction
|
||||
|
||||
function! s:CmpLoclist(a, b)
|
||||
return a:a['lnum'] - a:b['lnum']
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'subtype': 'Style' })
|
||||
return sort(loclist, 'syntastic#util#compareErrorItems')
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
|
@ -9,12 +9,21 @@
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
"
|
||||
" Checker option:
|
||||
"
|
||||
" - g:syntastic_xhtml_tidy_ignore_errors (list; default: [])
|
||||
" list of errors to ignore
|
||||
|
||||
if exists("g:loaded_syntastic_xhtml_tidy_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_xhtml_tidy_checker=1
|
||||
|
||||
if !exists('g:syntastic_xhtml_tidy_ignore_errors')
|
||||
let g:syntastic_xhtml_tidy_ignore_errors = []
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_xhtml_tidy_IsAvailable()
|
||||
return executable("tidy")
|
||||
endfunction
|
||||
@ -38,6 +47,15 @@ function! s:TidyEncOptByFenc()
|
||||
return get(tidy_opts, &fileencoding, '-utf8')
|
||||
endfunction
|
||||
|
||||
function! s:IgnoreErrror(text)
|
||||
for i in g:syntastic_xhtml_tidy_ignore_errors
|
||||
if stridx(a:text, i) != -1
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_xhtml_tidy_GetLocList()
|
||||
let encopt = s:TidyEncOptByFenc()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
@ -48,7 +66,15 @@ function! SyntaxCheckers_xhtml_tidy_GetLocList()
|
||||
\ '%Wline %l column %c - Warning: %m,' .
|
||||
\ '%Eline %l column %c - Error: %m,' .
|
||||
\ '%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr("")} })
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr("")} })
|
||||
|
||||
for n in range(len(loclist))
|
||||
if loclist[n]['valid'] && s:IgnoreErrror(loclist[n]['text']) == 1
|
||||
let loclist[n]['valid'] = 0
|
||||
endif
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
|
Loading…
Reference in New Issue
Block a user