mirror of
https://github.com/amix/vimrc
synced 2025-06-30 11:54:59 +08:00
Use syntastic instead of pyflakes (supports a ton of more languages)
This commit is contained in:
55
sources_non_forked/syntastic/syntax_checkers/html/jshint.vim
Normal file
55
sources_non_forked/syntastic/syntax_checkers/html/jshint.vim
Normal file
@ -0,0 +1,55 @@
|
||||
"============================================================================
|
||||
"File: jshint.vim
|
||||
"Description: Javascript syntax checker for HTML - using jshint
|
||||
"Maintainer: LCD 47 <lcd047@gmail.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.
|
||||
"============================================================================
|
||||
|
||||
if exists('g:loaded_syntastic_html_jshint_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_html_jshint_checker = 1
|
||||
|
||||
if !exists('g:syntastic_jshint_exec')
|
||||
let g:syntastic_jshint_exec = 'jshint'
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_html_jshint_conf')
|
||||
let g:syntastic_html_jshint_conf = ''
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_html_jshint_IsAvailable() dict
|
||||
let exe = expand(g:syntastic_jshint_exec)
|
||||
return executable(exe) &&
|
||||
\ syntastic#util#versionIsAtLeast(syntastic#util#getVersion(exe . ' --version'), [2,4])
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_html_jshint_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'exe': expand(g:syntastic_jshint_exec),
|
||||
\ 'args': (g:syntastic_html_jshint_conf != '' ? '--config ' . g:syntastic_html_jshint_conf : ''),
|
||||
\ 'args_after': '--verbose --extract always' })
|
||||
|
||||
let errorformat = '%A%f: line %l\, col %v\, %m \(%t%*\d\)'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr('')} })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'html',
|
||||
\ 'name': 'jshint'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
209
sources_non_forked/syntastic/syntax_checkers/html/tidy.vim
Normal file
209
sources_non_forked/syntastic/syntax_checkers/html/tidy.vim
Normal file
@ -0,0 +1,209 @@
|
||||
"============================================================================
|
||||
"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.
|
||||
"
|
||||
"============================================================================
|
||||
"
|
||||
" Checker option:
|
||||
"
|
||||
" - g:syntastic_html_tidy_ignore_errors (list; default: [])
|
||||
" list of errors to ignore
|
||||
" - g:syntastic_html_tidy_blocklevel_tags (list; default: [])
|
||||
" list of additional blocklevel tags, to be added to "--new-blocklevel-tags"
|
||||
" - g:syntastic_html_tidy_inline_tags (list; default: [])
|
||||
" list of additional inline tags, to be added to "--new-inline-tags"
|
||||
" - g:syntastic_html_tidy_empty_tags (list; default: [])
|
||||
" list of additional empty tags, to be added to "--new-empty-tags"
|
||||
|
||||
if exists("g:loaded_syntastic_html_tidy_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_html_tidy_checker = 1
|
||||
|
||||
if !exists('g:syntastic_html_tidy_ignore_errors')
|
||||
let g:syntastic_html_tidy_ignore_errors = []
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_html_tidy_blocklevel_tags')
|
||||
let g:syntastic_html_tidy_blocklevel_tags = []
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_html_tidy_inline_tags')
|
||||
let g:syntastic_html_tidy_inline_tags = []
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_html_tidy_empty_tags')
|
||||
let g:syntastic_html_tidy_empty_tags = []
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" 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',
|
||||
\'cp932': '-shiftjis',
|
||||
\'sjis': '-shiftjis',
|
||||
\'cp850': '-ibm858',
|
||||
\}
|
||||
return get(tidy_opts, &fileencoding, '-utf8')
|
||||
endfunction
|
||||
|
||||
let s:ignore_errors = [
|
||||
\ "<table> lacks \"summary\" attribute",
|
||||
\ "not approved by W3C",
|
||||
\ "<input> proprietary attribute \"placeholder\"",
|
||||
\ "<meta> proprietary attribute \"charset\"",
|
||||
\ "<meta> lacks \"content\" attribute",
|
||||
\ "inserting \"type\" attribute",
|
||||
\ "proprietary attribute \"data-",
|
||||
\ "missing <!DOCTYPE> declaration",
|
||||
\ "inserting implicit <body>",
|
||||
\ "inserting missing 'title' element",
|
||||
\ "unescaped & or unknown entity",
|
||||
\ "<input> attribute \"type\" has invalid value",
|
||||
\ "proprietary attribute \"role\"",
|
||||
\ "proprietary attribute \"aria-activedescendant\"",
|
||||
\ "proprietary attribute \"aria-atomic\"",
|
||||
\ "proprietary attribute \"aria-autocomplete\"",
|
||||
\ "proprietary attribute \"aria-busy\"",
|
||||
\ "proprietary attribute \"aria-checked\"",
|
||||
\ "proprietary attribute \"aria-controls\"",
|
||||
\ "proprietary attribute \"aria-describedby\"",
|
||||
\ "proprietary attribute \"aria-disabled\"",
|
||||
\ "proprietary attribute \"aria-dropeffect\"",
|
||||
\ "proprietary attribute \"aria-expanded\"",
|
||||
\ "proprietary attribute \"aria-flowto\"",
|
||||
\ "proprietary attribute \"aria-grabbed\"",
|
||||
\ "proprietary attribute \"aria-haspopup\"",
|
||||
\ "proprietary attribute \"aria-hidden\"",
|
||||
\ "proprietary attribute \"aria-invalid\"",
|
||||
\ "proprietary attribute \"aria-label\"",
|
||||
\ "proprietary attribute \"aria-labelledby\"",
|
||||
\ "proprietary attribute \"aria-level\"",
|
||||
\ "proprietary attribute \"aria-live\"",
|
||||
\ "proprietary attribute \"aria-multiline\"",
|
||||
\ "proprietary attribute \"aria-multiselectable\"",
|
||||
\ "proprietary attribute \"aria-orientation\"",
|
||||
\ "proprietary attribute \"aria-owns\"",
|
||||
\ "proprietary attribute \"aria-posinset\"",
|
||||
\ "proprietary attribute \"aria-pressed\"",
|
||||
\ "proprietary attribute \"aria-readonly\"",
|
||||
\ "proprietary attribute \"aria-relevant\"",
|
||||
\ "proprietary attribute \"aria-relevant\"",
|
||||
\ "proprietary attribute \"aria-required\"",
|
||||
\ "proprietary attribute \"aria-selected\"",
|
||||
\ "proprietary attribute \"aria-setsize\"",
|
||||
\ "proprietary attribute \"aria-sort\"",
|
||||
\ "proprietary attribute \"aria-valuemax\"",
|
||||
\ "proprietary attribute \"aria-valuemin\"",
|
||||
\ "proprietary attribute \"aria-valuenow\"",
|
||||
\ "proprietary attribute \"aria-valuetext\""
|
||||
\ ]
|
||||
|
||||
let s:blocklevel_tags = [
|
||||
\ "main",
|
||||
\ "section",
|
||||
\ "article",
|
||||
\ "aside",
|
||||
\ "header",
|
||||
\ "footer",
|
||||
\ "nav",
|
||||
\ "figure",
|
||||
\ "figcaption"
|
||||
\ ]
|
||||
|
||||
let s:inline_tags = [
|
||||
\ "video",
|
||||
\ "audio",
|
||||
\ "source",
|
||||
\ "embed",
|
||||
\ "mark",
|
||||
\ "progress",
|
||||
\ "meter",
|
||||
\ "time",
|
||||
\ "ruby",
|
||||
\ "rt",
|
||||
\ "rp",
|
||||
\ "canvas",
|
||||
\ "command",
|
||||
\ "details",
|
||||
\ "datalist"
|
||||
\ ]
|
||||
|
||||
let s:empty_tags = [
|
||||
\ "wbr",
|
||||
\ "keygen"
|
||||
\ ]
|
||||
|
||||
function! s:IgnoreError(text)
|
||||
for i in s:ignore_errors + g:syntastic_html_tidy_ignore_errors
|
||||
if stridx(a:text, i) != -1
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:NewTags(name)
|
||||
return syntastic#util#shescape(join( s:{a:name} + g:syntastic_html_tidy_{a:name}, ',' ))
|
||||
endfunction
|
||||
|
||||
function! s:Args()
|
||||
let args = s:TidyEncOptByFenc() .
|
||||
\ ' --new-blocklevel-tags ' . s:NewTags('blocklevel_tags') .
|
||||
\ ' --new-inline-tags ' . s:NewTags('inline_tags') .
|
||||
\ ' --new-empty-tags ' . s:NewTags('empty_tags') .
|
||||
\ ' -e'
|
||||
return args
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_html_tidy_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'args_after': s:Args(),
|
||||
\ 'tail': '2>&1' })
|
||||
|
||||
let errorformat =
|
||||
\ '%Wline %l column %v - Warning: %m,' .
|
||||
\ '%Eline %l column %v - Error: %m,' .
|
||||
\ '%-G%.%#'
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")},
|
||||
\ 'returns': [0, 1, 2] })
|
||||
|
||||
" filter out valid HTML5 from the errors
|
||||
for e in loclist
|
||||
if e['valid'] && s:IgnoreError(e['text']) == 1
|
||||
let e['valid'] = 0
|
||||
endif
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'html',
|
||||
\ 'name': 'tidy'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
102
sources_non_forked/syntastic/syntax_checkers/html/validator.vim
Normal file
102
sources_non_forked/syntastic/syntax_checkers/html/validator.vim
Normal file
@ -0,0 +1,102 @@
|
||||
"============================================================================
|
||||
"File: validator.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: LCD 47 <lcd047 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.
|
||||
"
|
||||
"============================================================================
|
||||
"
|
||||
" For detail;s about validator see: http://about.validator.nu/
|
||||
"
|
||||
" Checker options:
|
||||
"
|
||||
" - g:syntastic_html_validator_api (string; default: 'http://validator.nu/')
|
||||
" URL of the service to use for checking; leave it to the default to run the
|
||||
" checks against http://validator.nu/, or set it to 'http://localhost:8888/'
|
||||
" if you're running a local service as per http://about.validator.nu/#src
|
||||
"
|
||||
" - g:syntastic_html_validator_parser (string; default: empty)
|
||||
" parser to use; legal values are: xml, xmldtd, html, html5, html4, html4tr;
|
||||
" set it to 'html5' to check HTML5 files; see the wiki for reference:
|
||||
" http://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#parser
|
||||
"
|
||||
" - g:syntastic_html_validator_nsfilter (string; default: empty)
|
||||
" sets the nsfilter for the parser; see the wiki for details:
|
||||
" http://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#nsfilter
|
||||
|
||||
if exists("g:loaded_syntastic_html_validator_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_html_validator_checker=1
|
||||
|
||||
if !exists('g:syntastic_html_validator_api')
|
||||
let g:syntastic_html_validator_api = 'http://validator.nu/'
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_html_validator_parser')
|
||||
let g:syntastic_html_validator_parser = ''
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_html_validator_nsfilter')
|
||||
let g:syntastic_html_validator_nsfilter = ''
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_html_validator_Preprocess(errors)
|
||||
let out = []
|
||||
for e in a:errors
|
||||
let parts = matchlist(e, '\v^"([^"]+)"(.+)')
|
||||
if len(parts) >= 3
|
||||
" URL decode, except leave alone any "+"
|
||||
let parts[1] = substitute(parts[1], '\m%\(\x\x\)', '\=nr2char("0x".submatch(1))', 'g')
|
||||
let parts[1] = substitute(parts[1], '\m\\"', '"', 'g')
|
||||
let parts[1] = substitute(parts[1], '\m\\\\', '\\', 'g')
|
||||
call add(out, '"' . parts[1] . '"' . parts[2])
|
||||
endif
|
||||
endfor
|
||||
return out
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_html_validator_GetLocList() dict
|
||||
let fname = syntastic#util#shexpand('%')
|
||||
let makeprg = self.getExecEscaped() . ' -s --compressed -F out=gnu -F asciiquotes=yes' .
|
||||
\ (g:syntastic_html_validator_parser != '' ? ' -F parser=' . g:syntastic_html_validator_parser : '') .
|
||||
\ (g:syntastic_html_validator_nsfilter != '' ? ' -F nsfilter=' . g:syntastic_html_validator_nsfilter : '') .
|
||||
\ ' -F doc=@' . fname . '\;type=text/html\;filename=' . fname . ' ' . g:syntastic_html_validator_api
|
||||
|
||||
let errorformat =
|
||||
\ '%E"%f":%l: %trror: %m,' .
|
||||
\ '%E"%f":%l-%\d%\+: %trror: %m,' .
|
||||
\ '%E"%f":%l%\%.%c: %trror: %m,' .
|
||||
\ '%E"%f":%l%\%.%c-%\d%\+%\%.%\d%\+: %trror: %m,' .
|
||||
\ '%E"%f":%l: %trror fatal: %m,' .
|
||||
\ '%E"%f":%l-%\d%\+: %trror fatal: %m,' .
|
||||
\ '%E"%f":%l%\%.%c: %trror fatal: %m,' .
|
||||
\ '%E"%f":%l%\%.%c-%\d%\+%\%.%\d%\+: %trror fatal: %m,' .
|
||||
\ '%W"%f":%l: info %tarning: %m,' .
|
||||
\ '%W"%f":%l-%\d%\+: info %tarning: %m,' .
|
||||
\ '%W"%f":%l%\%.%c: info %tarning: %m,' .
|
||||
\ '%W"%f":%l%\%.%c-%\d%\+%\%.%\d%\+: info %tarning: %m'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'preprocess': 'SyntaxCheckers_html_validator_Preprocess',
|
||||
\ 'returns': [0] })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'html',
|
||||
\ 'name': 'validator',
|
||||
\ 'exec': 'curl' })
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
69
sources_non_forked/syntastic/syntax_checkers/html/w3.vim
Normal file
69
sources_non_forked/syntastic/syntax_checkers/html/w3.vim
Normal file
@ -0,0 +1,69 @@
|
||||
"============================================================================
|
||||
"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.
|
||||
"
|
||||
"============================================================================
|
||||
"
|
||||
" Checker option:
|
||||
"
|
||||
" - g:syntastic_html_w3_api (string; default: 'http://validator.w3.org/check')
|
||||
" URL of the service to use for checking; leave it to the default to run the
|
||||
" checks against http://validator.w3.org/, or set it to
|
||||
" 'http://localhost/w3c-validator/check' if you're running a local service
|
||||
|
||||
if exists("g:loaded_syntastic_html_w3_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_html_w3_checker = 1
|
||||
|
||||
if !exists('g:syntastic_html_w3_api')
|
||||
let g:syntastic_html_w3_api = 'http://validator.w3.org/check'
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_html_w3_GetLocList() dict
|
||||
let makeprg = self.getExecEscaped() . ' -s -F output=json ' .
|
||||
\ '-F uploaded_file=@' . syntastic#util#shexpand('%:p') . '\;type=text/html ' .
|
||||
\ g:syntastic_html_w3_api
|
||||
|
||||
let errorformat =
|
||||
\ '%A %\+{,' .
|
||||
\ '%C %\+"lastLine": %l\,%\?,' .
|
||||
\ '%C %\+"lastColumn": %c\,%\?,' .
|
||||
\ '%C %\+"message": "%m"\,%\?,' .
|
||||
\ '%C %\+"type": "%trror"\,%\?,' .
|
||||
\ '%-G %\+"type": "%tnfo"\,%\?,' .
|
||||
\ '%C %\+"subtype": "%tarning"\,%\?,' .
|
||||
\ '%Z %\+}\,,' .
|
||||
\ '%-G%.%#'
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")},
|
||||
\ 'returns': [0] })
|
||||
|
||||
for e in loclist
|
||||
let e['text'] = substitute(e['text'], '\m\\\([\"]\)', '\1', 'g')
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'html',
|
||||
\ 'name': 'w3',
|
||||
\ 'exec': 'curl' })
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
Reference in New Issue
Block a user