jslint.vim 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "============================================================================
  2. "File: jslint.vim
  3. "Description: Javascript syntax checker - using jslint
  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_javascript_jslint_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_javascript_jslint_checker = 1
  16. let s:save_cpo = &cpo
  17. set cpo&vim
  18. function! SyntaxCheckers_javascript_jslint_GetHighlightRegex(item)
  19. let term = matchstr(a:item['text'], '\mExpected .* and instead saw ''\zs.*\ze''')
  20. if term !=# ''
  21. let term = '\V\<' . escape(term, '\') . '\>'
  22. endif
  23. return term
  24. endfunction
  25. function! SyntaxCheckers_javascript_jslint_GetLocList() dict
  26. let makeprg = self.makeprgBuild({ 'args': '--white --nomen --regexp --plusplus --bitwise --newcap --sloppy --vars' })
  27. let errorformat =
  28. \ '%E %##%\d%\+ %m,'.
  29. \ '%-Z%.%#Line %l\, Pos %c,'.
  30. \ '%-G%.%#'
  31. return SyntasticMake({
  32. \ 'makeprg': makeprg,
  33. \ 'errorformat': errorformat,
  34. \ 'defaults': {'bufnr': bufnr('')} })
  35. endfunction
  36. call g:SyntasticRegistry.CreateAndRegisterChecker({
  37. \ 'filetype': 'javascript',
  38. \ 'name': 'jslint'})
  39. let &cpo = s:save_cpo
  40. unlet s:save_cpo
  41. " vim: set sw=4 sts=4 et fdm=marker: