w3.vim 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "============================================================================
  2. "File: w3.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  4. "Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
  5. "License: This program is free software. It comes without any warranty,
  6. " to the extent permitted by applicable law. You can redistribute
  7. " it and/or modify it under the terms of the Do What The Fuck You
  8. " Want To Public License, Version 2, as published by Sam Hocevar.
  9. " See http://sam.zoy.org/wtfpl/COPYING for more details.
  10. "
  11. "============================================================================
  12. if exists('g:loaded_syntastic_html_w3_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_html_w3_checker = 1
  16. if !exists('g:syntastic_html_w3_api')
  17. let g:syntastic_html_w3_api = 'http://validator.w3.org/check'
  18. endif
  19. let s:save_cpo = &cpo
  20. set cpo&vim
  21. function! SyntaxCheckers_html_w3_GetLocList() dict
  22. let makeprg = self.getExecEscaped() . ' -q -L -s -F output=json ' .
  23. \ '-F uploaded_file=@' . syntastic#util#shexpand('%:p') . '\;type=text/html ' .
  24. \ g:syntastic_html_w3_api
  25. let errorformat =
  26. \ '%A %\+{,' .
  27. \ '%C %\+"lastLine": %l\,%\?,' .
  28. \ '%C %\+"lastColumn": %c\,%\?,' .
  29. \ '%C %\+"message": "%m"\,%\?,' .
  30. \ '%C %\+"type": "%trror"\,%\?,' .
  31. \ '%-G %\+"type": "%tnfo"\,%\?,' .
  32. \ '%C %\+"subtype": "%tarning"\,%\?,' .
  33. \ '%Z %\+}\,,' .
  34. \ '%-G%.%#'
  35. let loclist = SyntasticMake({
  36. \ 'makeprg': makeprg,
  37. \ 'errorformat': errorformat,
  38. \ 'defaults': {'bufnr': bufnr('')},
  39. \ 'returns': [0] })
  40. for e in loclist
  41. let e['text'] = substitute(e['text'], '\m\\\([\"]\)', '\1', 'g')
  42. endfor
  43. return loclist
  44. endfunction
  45. call g:SyntasticRegistry.CreateAndRegisterChecker({
  46. \ 'filetype': 'html',
  47. \ 'name': 'w3',
  48. \ 'exec': 'curl' })
  49. let &cpo = s:save_cpo
  50. unlet s:save_cpo
  51. " vim: set sw=4 sts=4 et fdm=marker: