jsxhint.vim 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. "============================================================================
  2. "File: jsxhint.vim
  3. "Description: Javascript syntax checker - using jsxhint
  4. "Maintainer: Thomas Boyt <me@thomasboyt.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. if exists('g:loaded_syntastic_javascript_jsxhint_checker')
  12. finish
  13. endif
  14. let g:loaded_syntastic_javascript_jsxhint_checker = 1
  15. let s:save_cpo = &cpo
  16. set cpo&vim
  17. function! SyntaxCheckers_javascript_jsxhint_IsAvailable() dict " {{{1
  18. if !executable(self.getExec())
  19. return 0
  20. endif
  21. let version_output = syntastic#util#system(self.getExecEscaped() . ' --version')
  22. let parsed_ver = !v:shell_error && (version_output =~# '\m^JSXHint\>') ? syntastic#util#parseVersion(version_output) : []
  23. if len(parsed_ver)
  24. call self.setVersion(parsed_ver)
  25. else
  26. call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', split(version_output, "\n", 1))
  27. call syntastic#log#error("checker javascript/jsxhint: can't parse version string (abnormal termination?)")
  28. endif
  29. return syntastic#util#versionIsAtLeast(parsed_ver, [0, 4, 1])
  30. endfunction " }}}1
  31. function! SyntaxCheckers_javascript_jsxhint_GetLocList() dict " {{{1
  32. let makeprg = self.makeprgBuild({
  33. \ 'args_after': '--verbose' })
  34. let errorformat = '%A%f: line %l\, col %v\, %m \(%t%*\d\)'
  35. return SyntasticMake({
  36. \ 'makeprg': makeprg,
  37. \ 'errorformat': errorformat,
  38. \ 'defaults': {'bufnr': bufnr('')} })
  39. endfunction " }}}1
  40. call g:SyntasticRegistry.CreateAndRegisterChecker({
  41. \ 'filetype': 'javascript',
  42. \ 'name': 'jsxhint'})
  43. let &cpo = s:save_cpo
  44. unlet s:save_cpo
  45. " vim: set sw=4 sts=4 et fdm=marker: