jshint.vim 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. "============================================================================
  2. "File: jshint.vim
  3. "Description: Javascript syntax checker - using jshint
  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. if exists('g:loaded_syntastic_javascript_jshint_checker')
  12. finish
  13. endif
  14. let g:loaded_syntastic_javascript_jshint_checker = 1
  15. if !exists('g:syntastic_javascript_jshint_sort')
  16. let g:syntastic_javascript_jshint_sort = 1
  17. endif
  18. let s:save_cpo = &cpo
  19. set cpo&vim
  20. function! SyntaxCheckers_javascript_jshint_IsAvailable() dict
  21. call syntastic#log#deprecationWarn('jshint_exec', 'javascript_jshint_exec')
  22. if !executable(self.getExec())
  23. return 0
  24. endif
  25. let ver = self.getVersion()
  26. let s:jshint_new = syntastic#util#versionIsAtLeast(ver, [1, 1])
  27. return syntastic#util#versionIsAtLeast(ver, [1])
  28. endfunction
  29. function! SyntaxCheckers_javascript_jshint_GetLocList() dict
  30. call syntastic#log#deprecationWarn('javascript_jshint_conf', 'javascript_jshint_args',
  31. \ "'--config ' . syntastic#util#shexpand(OLD_VAR)")
  32. let makeprg = self.makeprgBuild({ 'args_after': (s:jshint_new ? '--verbose ' : '') })
  33. let errorformat = s:jshint_new ?
  34. \ '%A%f: line %l\, col %v\, %m \(%t%*\d\)' :
  35. \ '%E%f: line %l\, col %v\, %m'
  36. return SyntasticMake({
  37. \ 'makeprg': makeprg,
  38. \ 'errorformat': errorformat,
  39. \ 'defaults': {'bufnr': bufnr('')},
  40. \ 'returns': [0, 2] })
  41. endfunction
  42. call g:SyntasticRegistry.CreateAndRegisterChecker({
  43. \ 'filetype': 'javascript',
  44. \ 'name': 'jshint'})
  45. let &cpo = s:save_cpo
  46. unlet s:save_cpo
  47. " vim: set sw=4 sts=4 et fdm=marker: