2012-05-01 10:14:42 -04:00
|
|
|
"============================================================================
|
2012-05-01 10:23:22 -04:00
|
|
|
"File: w3.vim
|
2017-09-15 14:04:16 -04:00
|
|
|
"Description: Syntax checking plugin for syntastic
|
2012-05-01 10:14:42 -04:00
|
|
|
"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.
|
|
|
|
"
|
|
|
|
"============================================================================
|
2013-04-16 04:30:42 -04:00
|
|
|
|
2015-03-25 12:44:34 -04:00
|
|
|
if exists('g:loaded_syntastic_html_w3_checker')
|
2013-02-21 10:50:41 -05:00
|
|
|
finish
|
|
|
|
endif
|
2013-04-16 04:30:42 -04:00
|
|
|
let g:loaded_syntastic_html_w3_checker = 1
|
|
|
|
|
2014-01-03 04:29:08 -05:00
|
|
|
let s:save_cpo = &cpo
|
|
|
|
set cpo&vim
|
|
|
|
|
2019-01-28 14:02:58 -05:00
|
|
|
" Constants {{{1
|
|
|
|
|
|
|
|
let s:DEFAULTS = {
|
2019-01-30 15:12:32 -05:00
|
|
|
\ 'html': {
|
|
|
|
\ 'ctype': 'text/html',
|
|
|
|
\ 'doctype': 'HTML5' },
|
|
|
|
\ 'svg': {
|
|
|
|
\ 'ctype': 'image/svg+xml',
|
|
|
|
\ 'doctype': 'SVG 1.1' },
|
|
|
|
\ 'xhtml': {
|
|
|
|
\ 'ctype': 'application/xhtml+xml',
|
|
|
|
\ 'doctype': 'XHTML 1.1' } }
|
2019-01-28 14:02:58 -05:00
|
|
|
|
|
|
|
" }}}1
|
|
|
|
|
2019-01-30 15:12:32 -05:00
|
|
|
" @vimlint(EVL101, 1, l:ctype)
|
2019-01-28 14:02:58 -05:00
|
|
|
" @vimlint(EVL101, 1, l:doctype)
|
|
|
|
function! SyntaxCheckers_html_w3_GetLocList() dict " {{{1
|
2017-02-15 01:48:45 -05:00
|
|
|
let buf = bufnr('')
|
2019-01-28 14:02:58 -05:00
|
|
|
let type = self.getFiletype()
|
|
|
|
let fname = syntastic#util#shescape(fnamemodify(bufname(buf), ':p'))
|
2019-01-30 15:12:32 -05:00
|
|
|
let api = syntastic#util#var(type . '_w3_api', 'https://validator.w3.org/check')
|
2019-01-30 15:15:43 -05:00
|
|
|
|
2019-01-30 15:12:32 -05:00
|
|
|
for key in keys(s:DEFAULTS[type])
|
|
|
|
let l:{key} = syntastic#util#var(type . '_w3_' . key, get(s:DEFAULTS[type], key))
|
2019-01-28 14:02:58 -05:00
|
|
|
endfor
|
|
|
|
|
|
|
|
" vint: -ProhibitUsingUndeclaredVariable
|
|
|
|
let makeprg = self.getExecEscaped() . ' -q -L -s --compressed -F output=json' .
|
|
|
|
\ (doctype !=# '' ? ' -F doctype=' . syntastic#util#shescape(doctype) : '') .
|
|
|
|
\ ' -F uploaded_file=@' . fname .
|
2019-01-30 15:12:32 -05:00
|
|
|
\ '\;type=' . ctype .
|
2019-01-28 14:02:58 -05:00
|
|
|
\ '\;filename=' . fname .
|
|
|
|
\ ' ' . api
|
|
|
|
" vint: ProhibitUsingUndeclaredVariable
|
2013-07-12 01:08:41 -04:00
|
|
|
|
2013-04-16 04:30:42 -04:00
|
|
|
let errorformat =
|
|
|
|
\ '%A %\+{,' .
|
|
|
|
\ '%C %\+"lastLine": %l\,%\?,' .
|
|
|
|
\ '%C %\+"lastColumn": %c\,%\?,' .
|
|
|
|
\ '%C %\+"message": "%m"\,%\?,' .
|
|
|
|
\ '%C %\+"type": "%trror"\,%\?,' .
|
|
|
|
\ '%-G %\+"type": "%tnfo"\,%\?,' .
|
|
|
|
\ '%C %\+"subtype": "%tarning"\,%\?,' .
|
|
|
|
\ '%Z %\+}\,,' .
|
|
|
|
\ '%-G%.%#'
|
2013-07-12 01:08:41 -04:00
|
|
|
|
|
|
|
let loclist = SyntasticMake({
|
|
|
|
\ 'makeprg': makeprg,
|
|
|
|
\ 'errorformat': errorformat,
|
2015-03-25 12:44:34 -04:00
|
|
|
\ 'defaults': {'bufnr': bufnr('')},
|
2013-07-12 01:08:41 -04:00
|
|
|
\ 'returns': [0] })
|
2012-05-01 10:14:42 -04:00
|
|
|
|
2013-11-08 03:45:15 -05:00
|
|
|
for e in loclist
|
2013-11-04 16:00:51 -05:00
|
|
|
let e['text'] = substitute(e['text'], '\m\\\([\"]\)', '\1', 'g')
|
2013-04-15 04:21:52 -04:00
|
|
|
endfor
|
2012-05-01 10:14:42 -04:00
|
|
|
|
|
|
|
return loclist
|
2019-01-28 14:02:58 -05:00
|
|
|
endfunction " }}}1
|
|
|
|
" @vimlint(EVL104, 0, l:doctype)
|
2019-01-30 15:12:32 -05:00
|
|
|
" @vimlint(EVL101, 0, l:ctype)
|
2013-01-27 15:08:30 -05:00
|
|
|
|
|
|
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
|
|
|
\ 'filetype': 'html',
|
2014-01-03 03:43:01 -05:00
|
|
|
\ 'name': 'w3',
|
|
|
|
\ 'exec': 'curl' })
|
2013-01-27 15:08:30 -05:00
|
|
|
|
2014-01-03 04:29:08 -05:00
|
|
|
let &cpo = s:save_cpo
|
|
|
|
unlet s:save_cpo
|
|
|
|
|
2015-01-04 05:46:54 -05:00
|
|
|
" vim: set sw=4 sts=4 et fdm=marker:
|