validator.vim 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. "============================================================================
  2. "File: validator.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  4. "Maintainer: LCD 47 <lcd047 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_validator_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_html_validator_checker=1
  16. if !exists('g:syntastic_html_validator_api')
  17. let g:syntastic_html_validator_api = 'https://validator.nu/'
  18. endif
  19. if !exists('g:syntastic_html_validator_parser')
  20. let g:syntastic_html_validator_parser = ''
  21. endif
  22. if !exists('g:syntastic_html_validator_nsfilter')
  23. let g:syntastic_html_validator_nsfilter = ''
  24. endif
  25. let s:save_cpo = &cpo
  26. set cpo&vim
  27. function! SyntaxCheckers_html_validator_GetLocList() dict
  28. let fname = syntastic#util#shexpand('%')
  29. let makeprg = self.getExecEscaped() . ' -q -L -s --compressed -F out=gnu -F asciiquotes=yes' .
  30. \ (g:syntastic_html_validator_parser !=# '' ? ' -F parser=' . g:syntastic_html_validator_parser : '') .
  31. \ (g:syntastic_html_validator_nsfilter !=# '' ? ' -F nsfilter=' . g:syntastic_html_validator_nsfilter : '') .
  32. \ ' -F doc=@' . fname . '\;type=text/html\;filename=' . fname . ' ' . g:syntastic_html_validator_api
  33. let errorformat =
  34. \ '%E"%f":%l: %trror: %m,' .
  35. \ '%E"%f":%l-%\d%\+: %trror: %m,' .
  36. \ '%E"%f":%l%\%.%c: %trror: %m,' .
  37. \ '%E"%f":%l%\%.%c-%\d%\+%\%.%\d%\+: %trror: %m,' .
  38. \ '%E"%f":%l: %trror fatal: %m,' .
  39. \ '%E"%f":%l-%\d%\+: %trror fatal: %m,' .
  40. \ '%E"%f":%l%\%.%c: %trror fatal: %m,' .
  41. \ '%E"%f":%l%\%.%c-%\d%\+%\%.%\d%\+: %trror fatal: %m,' .
  42. \ '%W"%f":%l: info %tarning: %m,' .
  43. \ '%W"%f":%l-%\d%\+: info %tarning: %m,' .
  44. \ '%W"%f":%l%\%.%c: info %tarning: %m,' .
  45. \ '%W"%f":%l%\%.%c-%\d%\+%\%.%\d%\+: info %tarning: %m'
  46. return SyntasticMake({
  47. \ 'makeprg': makeprg,
  48. \ 'errorformat': errorformat,
  49. \ 'preprocess': 'validator',
  50. \ 'returns': [0] })
  51. endfunction
  52. call g:SyntasticRegistry.CreateAndRegisterChecker({
  53. \ 'filetype': 'html',
  54. \ 'name': 'validator',
  55. \ 'exec': 'curl' })
  56. let &cpo = s:save_cpo
  57. unlet s:save_cpo
  58. " vim: set sw=4 sts=4 et fdm=marker: