tern_lint.vim 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "============================================================================
  2. "File: tern_lint.vim
  3. "Description: Syntax checking plugin for syntastic
  4. "Maintainer: LCD 47 <lcd047@gmail.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_tern_lint_checker')
  12. finish
  13. endif
  14. let g:loaded_syntastic_javascript_tern_lint_checker = 1
  15. let s:save_cpo = &cpo
  16. set cpo&vim
  17. function! SyntaxCheckers_javascript_tern_lint_IsAvailable() dict
  18. return has('byte_offset') && executable(self.getExec())
  19. endfunction
  20. function! SyntaxCheckers_javascript_tern_lint_GetLocList() dict
  21. let makeprg = self.makeprgBuild({})
  22. let errorformat = '%f:%t:%l:%c:%n:%m'
  23. let loclist = SyntasticMake({
  24. \ 'makeprg': makeprg,
  25. \ 'errorformat': errorformat,
  26. \ 'preprocess': 'tern_lint',
  27. \ 'returns': [0] })
  28. for e in loclist
  29. if get(e, 'col', 0) && get(e, 'nr', 0)
  30. let e['hl'] = '\%>' . (e['col'] - 1) . 'c\%<' . (e['nr'] + 1) . 'c'
  31. endif
  32. let e['nr'] = 0
  33. endfor
  34. return loclist
  35. endfunction
  36. call g:SyntasticRegistry.CreateAndRegisterChecker({
  37. \ 'filetype': 'javascript',
  38. \ 'name': 'tern_lint',
  39. \ 'exec': 'tern-lint' })
  40. let &cpo = s:save_cpo
  41. unlet s:save_cpo
  42. " vim: set sw=4 sts=4 et fdm=marker: