Merge remote-tracking branch 'scrooloose/master'
This commit is contained in:
commit
96cb6a9556
@ -185,6 +185,8 @@ function! s:CacheErrors()
|
||||
for ft in split(fts, '\.')
|
||||
if s:Checkable(ft)
|
||||
let errors = SyntaxCheckers_{ft}_GetLocList()
|
||||
"keep only lines that effectively match an error/warning
|
||||
let errors = s:FilterLocList({'valid': 1}, errors)
|
||||
"make errors have type "E" by default
|
||||
call SyntasticAddToErrors(errors, {'type': 'E'})
|
||||
call extend(s:LocList(), errors)
|
||||
@ -529,10 +531,10 @@ endfunction
|
||||
" 'subtype' - all errors will be assigned the given subtype
|
||||
function! SyntasticMake(options)
|
||||
let old_loclist = getloclist(0)
|
||||
let old_makeprg = &makeprg
|
||||
let old_makeprg = &l:makeprg
|
||||
let old_shellpipe = &shellpipe
|
||||
let old_shell = &shell
|
||||
let old_errorformat = &errorformat
|
||||
let old_errorformat = &l:errorformat
|
||||
|
||||
if !s:running_windows && (s:uname !~ "FreeBSD")
|
||||
"this is a hack to stop the screen needing to be ':redraw'n when
|
||||
@ -542,19 +544,19 @@ function! SyntasticMake(options)
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'makeprg')
|
||||
let &makeprg = a:options['makeprg']
|
||||
let &l:makeprg = a:options['makeprg']
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'errorformat')
|
||||
let &errorformat = a:options['errorformat']
|
||||
let &l:errorformat = a:options['errorformat']
|
||||
endif
|
||||
|
||||
silent lmake!
|
||||
let errors = getloclist(0)
|
||||
|
||||
call setloclist(0, old_loclist)
|
||||
let &makeprg = old_makeprg
|
||||
let &errorformat = old_errorformat
|
||||
let &l:makeprg = old_makeprg
|
||||
let &l:errorformat = old_errorformat
|
||||
let &shellpipe=old_shellpipe
|
||||
let &shell=old_shell
|
||||
|
||||
|
@ -125,7 +125,7 @@ function! SyntaxCheckers_c_GetLocList()
|
||||
endif
|
||||
|
||||
" add optional config file parameters
|
||||
let makeprg .= syntastic#c#ReadConfig(g:syntastic_c_config_file)
|
||||
let makeprg .= ' '.syntastic#c#ReadConfig(g:syntastic_c_config_file)
|
||||
|
||||
" process makeprg
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg,
|
||||
|
@ -113,7 +113,7 @@ function! SyntaxCheckers_cpp_GetLocList()
|
||||
endif
|
||||
|
||||
" add optional config file parameters
|
||||
let makeprg .= syntastic#c#ReadConfig(g:syntastic_cpp_config_file)
|
||||
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_cpp_config_file)
|
||||
|
||||
" process makeprg
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg,
|
||||
|
@ -10,7 +10,7 @@
|
||||
"
|
||||
"============================================================================
|
||||
function! SyntaxCheckers_go_GetLocList()
|
||||
let makeprg = 'go build -o /dev/null %'
|
||||
let makeprg = 'go build -o /dev/null'
|
||||
let errorformat = '%f:%l:%c:%m,%f:%l%m,%-G#%.%#'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
@ -14,73 +14,16 @@ if exists("loaded_html_syntax_checker")
|
||||
endif
|
||||
let loaded_html_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have tidy or grep installed
|
||||
if !executable("tidy") || !executable("grep")
|
||||
finish
|
||||
if !exists('g:syntastic_html_checker')
|
||||
let g:syntastic_html_checker = "tidy"
|
||||
endif
|
||||
|
||||
" TODO: join this with xhtml.vim for DRY's sake?
|
||||
function! s:TidyEncOptByFenc()
|
||||
let tidy_opts = {
|
||||
\'utf-8' : '-utf8',
|
||||
\'ascii' : '-ascii',
|
||||
\'latin1' : '-latin1',
|
||||
\'iso-2022-jp' : '-iso-2022',
|
||||
\'cp1252' : '-win1252',
|
||||
\'macroman' : '-mac',
|
||||
\'utf-16le' : '-utf16le',
|
||||
\'utf-16' : '-utf16',
|
||||
\'big5' : '-big5',
|
||||
\'sjis' : '-shiftjis',
|
||||
\'cp850' : '-ibm858',
|
||||
\}
|
||||
return get(tidy_opts, &fileencoding, '-utf8')
|
||||
endfunction
|
||||
|
||||
let s:ignore_html_errors = [
|
||||
\ "<table> lacks \"summary\" attribute",
|
||||
\ "not approved by W3C",
|
||||
\ "attribute \"placeholder\"",
|
||||
\ "<meta> proprietary attribute \"charset\"",
|
||||
\ "<meta> lacks \"content\" attribute",
|
||||
\ "inserting \"type\" attribute",
|
||||
\ "proprietary attribute \"data-"
|
||||
\]
|
||||
|
||||
function! s:ValidateError(text)
|
||||
let valid = 0
|
||||
for i in s:ignore_html_errors
|
||||
if stridx(a:text, i) != -1
|
||||
let valid = 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
return valid
|
||||
endfunction
|
||||
|
||||
|
||||
function! SyntaxCheckers_html_GetLocList()
|
||||
|
||||
let encopt = s:TidyEncOptByFenc()
|
||||
let makeprg="tidy ".encopt." --new-blocklevel-tags ".shellescape('section, article, aside, hgroup, header, footer, nav, figure, figcaption')." --new-inline-tags ".shellescape('video, audio, embed, mark, progress, meter, time, ruby, rt, rp, canvas, command, details, datalist')." --new-empty-tags ".shellescape('wbr, keygen')." -e ".shellescape(expand('%'))." 2>&1"
|
||||
let errorformat='%Wline %l column %c - Warning: %m,%Eline %l column %c - Error: %m,%-G%.%#,%-G%.%#'
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
" process loclist since we need to add some info and filter out valid HTML5
|
||||
" from the errors
|
||||
let n = len(loclist) - 1
|
||||
let bufnum = bufnr("")
|
||||
while n >= 0
|
||||
let i = loclist[n]
|
||||
" filter out valid HTML5
|
||||
if s:ValidateError(i['text']) == 1
|
||||
unlet loclist[n]
|
||||
else
|
||||
"the file name isnt in the output so stick in the buf num manually
|
||||
let i['bufnr'] = bufnum
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
if g:syntastic_html_checker == "tidy"
|
||||
if executable("tidy") && executable("grep")
|
||||
runtime! syntax_checkers/html/tidy.vim
|
||||
endif
|
||||
elseif g:syntastic_html_checker == "w3"
|
||||
if executable("curl") && executable("sed")
|
||||
runtime! syntax_checkers/html/w3.vim
|
||||
endif
|
||||
endif
|
||||
|
74
syntax_checkers/html/tidy.vim
Normal file
74
syntax_checkers/html/tidy.vim
Normal file
@ -0,0 +1,74 @@
|
||||
"============================================================================
|
||||
"File: tidy.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
" TODO: join this with xhtml.vim for DRY's sake?
|
||||
function! s:TidyEncOptByFenc()
|
||||
let tidy_opts = {
|
||||
\'utf-8' : '-utf8',
|
||||
\'ascii' : '-ascii',
|
||||
\'latin1' : '-latin1',
|
||||
\'iso-2022-jp' : '-iso-2022',
|
||||
\'cp1252' : '-win1252',
|
||||
\'macroman' : '-mac',
|
||||
\'utf-16le' : '-utf16le',
|
||||
\'utf-16' : '-utf16',
|
||||
\'big5' : '-big5',
|
||||
\'sjis' : '-shiftjis',
|
||||
\'cp850' : '-ibm858',
|
||||
\}
|
||||
return get(tidy_opts, &fileencoding, '-utf8')
|
||||
endfunction
|
||||
|
||||
let s:ignore_html_errors = [
|
||||
\ "<table> lacks \"summary\" attribute",
|
||||
\ "not approved by W3C",
|
||||
\ "attribute \"placeholder\"",
|
||||
\ "<meta> proprietary attribute \"charset\"",
|
||||
\ "<meta> lacks \"content\" attribute",
|
||||
\ "inserting \"type\" attribute",
|
||||
\ "proprietary attribute \"data-"
|
||||
\]
|
||||
|
||||
function! s:ValidateError(text)
|
||||
let valid = 0
|
||||
for i in s:ignore_html_errors
|
||||
if stridx(a:text, i) != -1
|
||||
let valid = 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
return valid
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_html_GetLocList()
|
||||
let encopt = s:TidyEncOptByFenc()
|
||||
let makeprg="tidy ".encopt." --new-blocklevel-tags ".shellescape('section, article, aside, hgroup, header, footer, nav, figure, figcaption')." --new-inline-tags ".shellescape('video, audio, embed, mark, progress, meter, time, ruby, rt, rp, canvas, command, details, datalist')." --new-empty-tags ".shellescape('wbr, keygen')." -e ".shellescape(expand('%'))." 2>&1"
|
||||
let errorformat='%Wline %l column %c - Warning: %m,%Eline %l column %c - Error: %m,%-G%.%#,%-G%.%#'
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
" process loclist since we need to add some info and filter out valid HTML5
|
||||
" from the errors
|
||||
let n = len(loclist) - 1
|
||||
let bufnum = bufnr("")
|
||||
while n >= 0
|
||||
let i = loclist[n]
|
||||
" filter out valid HTML5
|
||||
if s:ValidateError(i['text']) == 1
|
||||
unlet loclist[n]
|
||||
else
|
||||
"the file name isnt in the output so stick in the buf num manually
|
||||
let i['bufnr'] = bufnum
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
|
||||
return loclist
|
||||
endfunction
|
32
syntax_checkers/html/w3.vim
Normal file
32
syntax_checkers/html/w3.vim
Normal file
@ -0,0 +1,32 @@
|
||||
"============================================================================
|
||||
"File: w3.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
function! SyntaxCheckers_html_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 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
|
||||
|
||||
return loclist
|
||||
endfunction
|
@ -41,7 +41,7 @@ function! SyntaxCheckers_php_GetLocList()
|
||||
let errors = []
|
||||
|
||||
let makeprg = "php -l -d error_reporting=E_ALL -d display_errors=0 -d error_log='' ".shellescape(expand('%'))
|
||||
let errorformat='%-GNo syntax errors detected in%.%#,PHP Parse error: %#syntax %trror\, %m in %f on line %l,PHP Fatal %trror: %m in %f on line %l,%-GErrors parsing %.%#,%-G\s%#,Parse error: %#syntax %trror\, %m in %f on line %l,Fatal %trror: %m in %f on line %l'
|
||||
let errorformat='%-GNo syntax errors detected in%.%#,PHP Parse error: %#syntax %trror\, %m in %f on line %l,PHP Fatal %trror: %m in %f on line %l,%-GErrors parsing %.%#,%-G\s%#,Parse error: %#syntax %trror\, %m in %f on line %l,Fatal %trror: %m in %f on line %l,PHP Parse %trror: %m in %f on line %l'
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
if empty(errors) && !g:syntastic_phpcs_disable && executable("phpcs")
|
||||
|
@ -24,7 +24,7 @@ if !exists("g:syntastic_puppet_lint_disable")
|
||||
endif
|
||||
|
||||
if !executable("puppet-lint")
|
||||
let g:syntastic_puppet_lint_disable = 0
|
||||
let g:syntastic_puppet_lint_disable = 1
|
||||
endif
|
||||
|
||||
function! s:PuppetExtractVersion()
|
||||
@ -44,7 +44,7 @@ let s:puppetVersion = s:PuppetExtractVersion()
|
||||
let s:lintVersion = s:PuppetLintExtractVersion()
|
||||
|
||||
if !(s:lintVersion[0] >= '0' && s:lintVersion[1] >= '1' && s:lintVersion[2] >= '10')
|
||||
let g:syntastic_puppet_lint_disable = 0
|
||||
let g:syntastic_puppet_lint_disable = 1
|
||||
endif
|
||||
|
||||
function! s:getPuppetLintErrors()
|
||||
|
@ -6,9 +6,6 @@
|
||||
"
|
||||
"============================================================================
|
||||
function! SyntaxCheckers_python_GetHighlightRegex(i)
|
||||
if a:i['type'] ==# 'E'
|
||||
let a:i['text'] = "Syntax error"
|
||||
endif
|
||||
if match(a:i['text'], 'is assigned to but never used') > -1
|
||||
\ || match(a:i['text'], 'imported but unused') > -1
|
||||
\ || match(a:i['text'], 'undefined name') > -1
|
||||
|
Loading…
x
Reference in New Issue
Block a user