closurecompiler.vim 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. "============================================================================
  2. "File: closurecompiler.vim
  3. "Description: Javascript syntax checker - using Google Closure Compiler
  4. "Maintainer: Motohiro Takayama <mootoh 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_closurecompiler_checker')
  12. finish
  13. endif
  14. let g:loaded_syntastic_javascript_closurecompiler_checker = 1
  15. let s:save_cpo = &cpo
  16. set cpo&vim
  17. function! SyntaxCheckers_javascript_closurecompiler_IsAvailable() dict
  18. call syntastic#log#deprecationWarn('javascript_closure_compiler_path', 'javascript_closurecompiler_path')
  19. if !executable(self.getExec())
  20. return 0
  21. endif
  22. let s:has_script = exists('g:syntastic_javascript_closurecompiler_script')
  23. if s:has_script
  24. return 1
  25. endif
  26. let cp = get(g:, 'syntastic_javascript_closurecompiler_path', '')
  27. call self.log('g:syntastic_javascript_closurecompiler_path =', cp)
  28. let jar = expand(cp, 1)
  29. call self.log('filereadable(' . string(jar) . ') = ' . filereadable(jar))
  30. return filereadable(jar)
  31. endfunction
  32. function! SyntaxCheckers_javascript_closurecompiler_GetLocList() dict
  33. call syntastic#log#deprecationWarn('javascript_closure_compiler_options', 'javascript_closurecompiler_args')
  34. call syntastic#log#deprecationWarn('javascript_closure_compiler_file_list', 'javascript_closurecompiler_file_list')
  35. let flist = expand(get(g:, 'syntastic_javascript_closurecompiler_file_list', ''), 1)
  36. if filereadable(flist)
  37. let file_list = map( readfile(flist), 'expand(v:var, 1)' )
  38. else
  39. let file_list = [expand('%', 1)]
  40. endif
  41. let makeprg = self.makeprgBuild({
  42. \ 'exe_after': (s:has_script ? [] : ['-jar', expand(g:syntastic_javascript_closurecompiler_path, 1)]),
  43. \ 'args_after': '--js',
  44. \ 'fname': file_list })
  45. let errorformat =
  46. \ '%-GOK,'.
  47. \ '%E%f:%l: ERROR - %m,'.
  48. \ '%W%f:%l: WARNING - %m,'.
  49. \ '%Z%p^'
  50. return SyntasticMake({
  51. \ 'makeprg': makeprg,
  52. \ 'errorformat': errorformat })
  53. endfunction
  54. call g:SyntasticRegistry.CreateAndRegisterChecker({
  55. \ 'filetype': 'javascript',
  56. \ 'name': 'closurecompiler',
  57. \ 'exec': get(g:, 'syntastic_javascript_closurecompiler_script', 'java')})
  58. let &cpo = s:save_cpo
  59. unlet s:save_cpo
  60. " vim: set sw=4 sts=4 et fdm=marker: