Nimbin[12]?Mirrors & Forks / syntastic / commits / f6ec8a41

syntastic git · master

syntastic vim plugin (fork)

vim fork · first commit 2009-07-10 · last commit 2022-07-10 (4 years ago) · synced 3 days ago · upstream: github.com/vim-syntastic/syntastic

Vim Script 99%
git clone https://git.christianimmanuel.de/mirrors-forks/syntastic.gitwget https://git.christianimmanuel.de/mirrors-forks/syntastic/archive/syntastic.tar.gz

Checker html/validator can be used for xhtml and svg.

LCD 47 · 2019-01-22 13:06 · f6ec8a411a89478c7683b35b80afd57d760119bb

 doc/syntastic-checkers.txt         | 198 +++++++++++++++++++++++++++++++++++++
 plugin/syntastic.vim               |   2 +-
 plugin/syntastic/registry.vim      |   1 +
 syntax_checkers/html/validator.vim |  56 ++++++++---
 4 files changed, 240 insertions(+), 17 deletions(-)

diff --git a/doc/syntastic-checkers.txt b/doc/syntastic-checkers.txt
index b2c347ba..9f9d8b0f 100644
--- a/doc/syntastic-checkers.txt
+++ b/doc/syntastic-checkers.txt
@@ -107,6 +107,7 @@ SYNTAX CHECKERS BY LANGUAGE                          *syntastic-checkers-lang*
     Solidity.................................|syntastic-checkers-solidity|
     SQL......................................|syntastic-checkers-sql|
     Stylus...................................|syntastic-checkers-stylus|
+    SVG......................................|syntastic-checkers-svg|
 
     Tcl......................................|syntastic-checkers-tcl|
     TeX......................................|syntastic-checkers-tex|
@@ -3132,6 +3133,13 @@ Sets the "nsfilter" for the parser. See:
 
     https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#nsfilter
 
+                                         *'g:syntastic_html_validator_schema'*
+Type: string
+Default: empty
+Sets the "schema" for the parser. See:
+
+    https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#schema
+
                                            *'g:syntastic_html_validator_exec'*
 Type: string
 Default: "curl"
@@ -3153,6 +3161,8 @@ You can lookup the meaning of these codes in cURL's manual:
     
     http://curl.haxx.se/docs/manpage.html#EXIT
 
+See also: |syntastic-svg-validator|, |syntastic-xhtml-validator|.
+
 ------------------------------------------------------------------------------
 10. W3                                                     *syntastic-html-w3*
 
@@ -6563,6 +6573,103 @@ You might also find useful the "vim-stylus" plugin:
 
     https://github.com/wavded/vim-stylus
 
+==============================================================================
+SYNTAX CHECKERS FOR SVG                               *syntastic-checkers-svg*
+
+The following checkers are available for SVG (filetype "svg"):
+
+    1. Validator................|syntastic-svg-validator|
+
+------------------------------------------------------------------------------
+1. Validator                                         *syntastic-svg-validator*
+
+Name:        validator
+Maintainer:  LCD 47 <lcd047@gmail.com>
+
+"Validator" is a non-DTD-based HTML linter.  See the project's page for
+details:
+
+    http://validator.github.io/validator/
+
+As a syntastic linter, you can validate your files against the online service
+(see https://validator.nu/), or you can install "vnu.jar":
+
+    https://github.com/validator/validator/releases/latest
+
+then run it as a HTTP server: >
+    $ java -Xss512k -cp /path/to/vnu.jar nu.validator.servlet.Main 8888
+<
+Requirement~
+
+This checker uses cURL:
+
+    http://curl.haxx.se/
+
+Checker options~
+
+                                             *'g:syntastic_svg_validator_api'*
+Type: string
+Default: "http://validator.nu/"
+URL of the service to use for checking. Leave it to the default to run the
+checks against "https://validator.nu/", or set it to "http://localhost:8888/"
+if you have "vnu.jar" installed, and you're running it as a standalone HTTP
+server. See:
+
+    http://validator.github.io/validator/#standalone
+
+                                          *'g:syntastic_svg_validator_parser'*
+Type: string
+Default: empty
+Parser to use. Legal values are: "xml", "xmldtd", "html", "html5", "html4",
+and "html4tr". References:
+
+    https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#parser
+
+                                        *'g:syntastic_svg_validator_nsfilter'*
+Type: string
+Default: empty
+Sets the "nsfilter" for the parser. See:
+
+    https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#nsfilter
+
+                                          *'g:syntastic_svg_validator_schema'*
+Type: string
+Default: empty
+Sets the "schema" for the parser. See:
+
+    https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#schema
+
+                                            *'g:syntastic_svg_validator_exec'*
+Type: string
+Default: "curl"
+Path to the "cURL" executable. Override it with a full path if your "cURL" is
+not installed in a standard location.
+
+This checker doesn't call the "makeprgBuild()" function, and thus it ignores
+the usual 'g:syntastic_svg_validator_<option>' variables. The only exception
+is 'g:syntastic_svg_validator_exec', which can be used to override the path
+to the "cURL" executable.
+
+Note~
+
+Non-zero exit codes from "cURL" are typically network errors, and are signaled
+by syntastic with messages such as: >
+    syntastic: error: checker svg/validator returned abnormal status 26
+<
+You can lookup the meaning of these codes in cURL's manual:
+    
+    http://curl.haxx.se/docs/manpage.html#EXIT
+
+Example~
+>
+    let g:syntastic_svg_validator_parser = 'xml'
+    let g:syntastic_svg_validator_schema = 
+        \ 'http://s.validator.nu/svg-xhtml5-rdf-mathml.rnc ' .
+        \ 'http://s.validator.nu/html5/assertions.sch ' .
+        \ 'http://c.validator.nu/all/'
+<
+See also: |syntastic-html-validator|, |syntastic-xhtml-validator|.
+
 ==============================================================================
 SYNTAX CHECKERS FOR TCL                               *syntastic-checkers-tcl*
 
@@ -7375,6 +7482,7 @@ The following checkers are available for xHTML (filetype "xhtml"):
     1. HTML Tidy................|syntastic-xhtml-tidy|
     2. jshint...................|syntastic-xhtml-jshint|
     3. proselint................|syntastic-xhtml-proselint|
+    4. Validator................|syntastic-xhtml-validator|
 
 ------------------------------------------------------------------------------
 1. HTML tidy                                            *syntastic-xhtml-tidy*
@@ -7470,6 +7578,96 @@ See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|,
 |syntastic-rst-proselint|, |syntastic-tex-proselint|,
 |syntastic-texinfo-proselint|, |syntastic-text-proselint|.
 
+------------------------------------------------------------------------------
+4. Validator                                       *syntastic-xhtml-validator*
+
+Name:        validator
+Maintainer:  LCD 47 <lcd047@gmail.com>
+
+"Validator" is a non-DTD-based HTML linter.  See the project's page for
+details:
+
+    http://validator.github.io/validator/
+
+As a syntastic linter, you can validate your files against the online service
+(see https://validator.nu/), or you can install "vnu.jar":
+
+    https://github.com/validator/validator/releases/latest
+
+then run it as a HTTP server: >
+    $ java -Xss512k -cp /path/to/vnu.jar nu.validator.servlet.Main 8888
+<
+Requirement~
+
+This checker uses cURL:
+
+    http://curl.haxx.se/
+
+Checker options~
+
+                                           *'g:syntastic_xhtml_validator_api'*
+Type: string
+Default: "http://validator.nu/"
+URL of the service to use for checking. Leave it to the default to run the
+checks against "https://validator.nu/", or set it to "http://localhost:8888/"
+if you have "vnu.jar" installed, and you're running it as a standalone HTTP
+server. See:
+
+    http://validator.github.io/validator/#standalone
+
+                                        *'g:syntastic_xhtml_validator_parser'*
+Type: string
+Default: empty
+Parser to use. Legal values are: "xml", "xmldtd", "html", "html5", "html4",
+and "html4tr". References:
+
+    https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#parser
+
+                                      *'g:syntastic_xhtml_validator_nsfilter'*
+Type: string
+Default: empty
+Sets the "nsfilter" for the parser. See:
+
+    https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#nsfilter
+
+                                        *'g:syntastic_xhtml_validator_schema'*
+Type: string
+Default: empty
+Sets the "schema" for the parser. See:
+
+    https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#schema
+
+                                          *'g:syntastic_xhtml_validator_exec'*
+Type: string
+Default: "curl"
+Path to the "cURL" executable. Override it with a full path if your "cURL" is
+not installed in a standard location.
+
+This checker doesn't call the "makeprgBuild()" function, and thus it ignores
+the usual 'g:syntastic_xhtml_validator_<option>' variables. The only exception
+is 'g:syntastic_xhtml_validator_exec', which can be used to override the path
+to the "cURL" executable.
+
+Note~
+
+Non-zero exit codes from "cURL" are typically network errors, and are signaled
+by syntastic with messages such as: >
+    syntastic: error: checker xhtml/validator returned abnormal status 26
+<
+You can lookup the meaning of these codes in cURL's manual:
+    
+    http://curl.haxx.se/docs/manpage.html#EXIT
+
+Example~
+>
+    let g:syntastic_xhtml_validator_parser = 'xmldtd'
+    let g:syntastic_xhtml_validator_schema = 
+        \ 'http://s.validator.nu/xhtml5.rnc ' .
+        \ 'http://s.validator.nu/html5/assertions.sch ' .
+        \ 'http://c.validator.nu/all/
+<
+See also: |syntastic-html-validator|, |syntastic-svg-validator|.
+
 ==============================================================================
 SYNTAX CHECKERS FOR XML                               *syntastic-checkers-xml*
 
diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim
index c30b929a..3ee37339 100644
--- a/plugin/syntastic.vim
+++ b/plugin/syntastic.vim
@@ -19,7 +19,7 @@ if has('reltime')
     lockvar! g:_SYNTASTIC_START
 endif
 
-let g:_SYNTASTIC_VERSION = '3.9.0-23'
+let g:_SYNTASTIC_VERSION = '3.9.0-24'
 lockvar g:_SYNTASTIC_VERSION
 
 " Sanity checks {{{1
diff --git a/plugin/syntastic/registry.vim b/plugin/syntastic/registry.vim
index 2796233a..4640bf76 100644
--- a/plugin/syntastic/registry.vim
+++ b/plugin/syntastic/registry.vim
@@ -92,6 +92,7 @@ let s:_DEFAULT_CHECKERS = {
         \ 'solidity':      ['solc'],
         \ 'sql':           ['sqlint'],
         \ 'stylus':        ['stylint'],
+        \ 'svg':           [],
         \ 'tcl':           ['nagelfar'],
         \ 'tex':           ['lacheck', 'chktex'],
         \ 'texinfo':       ['makeinfo'],
diff --git a/syntax_checkers/html/validator.vim b/syntax_checkers/html/validator.vim
index 007be843..b1b01e6d 100644
--- a/syntax_checkers/html/validator.vim
+++ b/syntax_checkers/html/validator.vim
@@ -15,28 +15,48 @@ if exists('g:loaded_syntastic_html_validator_checker')
 endif
 let g:loaded_syntastic_html_validator_checker=1
 
-if !exists('g:syntastic_html_validator_api')
-    let g:syntastic_html_validator_api = 'https://validator.nu/'
-endif
+let s:save_cpo = &cpo
+set cpo&vim
 
-if !exists('g:syntastic_html_validator_parser')
-    let g:syntastic_html_validator_parser = ''
-endif
+" Constants {{{1
 
-if !exists('g:syntastic_html_validator_nsfilter')
-    let g:syntastic_html_validator_nsfilter = ''
-endif
+let s:DEFAULTS = {
+    \ 'api':      'https://validator.nu/',
+    \ 'nsfilter': '',
+    \ 'parser':   '',
+    \ 'schema':   '' }
 
-let s:save_cpo = &cpo
-set cpo&vim
+let s:CONTENT_TYPE = {
+    \ 'html': 'text/html',
+    \ 'svg':  'image/svg+xml',
+    \ 'xhtm': 'application/xhtml+xml' }
+
+" }}}1
 
-function! SyntaxCheckers_html_validator_GetLocList() dict
+" @vimlint(EVL101, 1, l:api)
+" @vimlint(EVL101, 1, l:nsfilter)
+" @vimlint(EVL101, 1, l:parser)
+" @vimlint(EVL101, 1, l:schema)
+function! SyntaxCheckers_html_validator_GetLocList() dict " {{{1
     let buf = bufnr('')
+    let type = self.getFiletype()
     let fname = syntastic#util#shescape(fnamemodify(bufname(buf), ':p'))
+
+    for key in keys(s:DEFAULTS)
+        let l:{key} = syntastic#util#var(type . '_validator_' . key, get(s:DEFAULTS, key))
+    endfor
+    let ctype = get(s:CONTENT_TYPE, type, '')
+
+    " vint: -ProhibitUsingUndeclaredVariable
     let makeprg = self.getExecEscaped() . ' -q -L -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
+        \ (nsfilter !=# '' ? ' -F nsfilter=' . syntastic#util#shescape(nsfilter) : '') .
+        \ (parser !=# '' ? ' -F parser=' . parser : '') .
+        \ (schema !=# '' ? ' -F schema=' . syntastic#util#shescape(schema) : '') .
+        \ ' -F doc=@' . fname .
+            \ (ctype !=# '' ? '\;type=' . ctype : '') .
+            \ '\;filename=' . fname .
+        \ ' ' . api
+    " vint: ProhibitUsingUndeclaredVariable
 
     let errorformat =
         \ '%E"%f":%l: %trror: %m,' .
@@ -57,7 +77,11 @@ function! SyntaxCheckers_html_validator_GetLocList() dict
         \ 'errorformat': errorformat,
         \ 'preprocess': 'validator',
         \ 'returns': [0] })
-endfunction
+endfunction " }}}1
+" @vimlint(EVL101, 0, l:schema)
+" @vimlint(EVL101, 0, l:parser)
+" @vimlint(EVL101, 0, l:nsfilter)
+" @vimlint(EVL101, 0, l:api)
 
 call g:SyntasticRegistry.CreateAndRegisterChecker({
     \ 'filetype': 'html',