From 243becc5dd83c25fcd2bd46a54f194757236f25d Mon Sep 17 00:00:00 2001 From: Motohiro Takayama Date: Fri, 4 May 2012 18:06:51 -0700 Subject: [PATCH 1/5] Javascript syntax check with Google Closure Compiler. --- syntax_checkers/javascript.vim | 2 +- syntax_checkers/javascript/gcc.vim | 37 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 syntax_checkers/javascript/gcc.vim diff --git a/syntax_checkers/javascript.vim b/syntax_checkers/javascript.vim index 3d5236c4..bcc8da67 100644 --- a/syntax_checkers/javascript.vim +++ b/syntax_checkers/javascript.vim @@ -19,5 +19,5 @@ if exists("loaded_javascript_syntax_checker") endif let loaded_javascript_syntax_checker = 1 -let s:supported_checkers = ["gjslint", "jslint", "jsl", "jshint"] +let s:supported_checkers = ["gjslint", "jslint", "jsl", "jshint", "gcc"] call SyntasticLoadChecker(s:supported_checkers, 'javascript') diff --git a/syntax_checkers/javascript/gcc.vim b/syntax_checkers/javascript/gcc.vim new file mode 100644 index 00000000..e5c28d16 --- /dev/null +++ b/syntax_checkers/javascript/gcc.vim @@ -0,0 +1,37 @@ +"============================================================================ +"File: gcc.vim +"Description: Javascript syntax checker - using Google Closure Compiler +"Maintainer: Motohiro Takayama +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +"============================================================================ +" +" To enable this plugin, edit the .vimc like this; +" +" let g:syntastic_javascript_checker = "gcc" +" +" and set the path to the Google Closure Compiler: +" +" let g:syntastic_javascript_closure_compiler_path = '/path/to/google-closure-compiler.jar' +" +" It takes additional options for Google Closure Compiler with the variable +" g:syntastic_javascript_closure_compiler_options. +" + +if !exists("g:syntastic_javascript_closure_compiler_options") + let g:syntastic_javascript_closure_compiler_options = "" +endif + +"bail if the user does not specify the path to closure compiler. +if !exists("g:syntastic_javascript_closure_compiler_path") + finish +endif + +function! SyntaxCheckers_javascript_GetLocList() + let makeprg = 'java -jar ' . g:syntastic_javascript_closure_compiler_path . ' ' . g:syntastic_javascript_closure_compiler_options . ' --js ' . shellescape(expand('%')) + let errorformat = '%-GOK,%E%f:%l: ERROR - %m,%Z%p^,%W%f:%l: WARNING - %m,%Z%p^' + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endfunction From 2d0bb48dd77227fb23bb344a6beacf797734b73e Mon Sep 17 00:00:00 2001 From: Motohiro Takayama Date: Fri, 4 May 2012 18:20:19 -0700 Subject: [PATCH 2/5] 1 byte typo. --- syntax_checkers/javascript/gcc.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax_checkers/javascript/gcc.vim b/syntax_checkers/javascript/gcc.vim index e5c28d16..69cd8b5b 100644 --- a/syntax_checkers/javascript/gcc.vim +++ b/syntax_checkers/javascript/gcc.vim @@ -9,7 +9,7 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. "============================================================================ " -" To enable this plugin, edit the .vimc like this; +" To enable this plugin, edit the .vimc like this: " " let g:syntastic_javascript_checker = "gcc" " From 3e6687e479805bb6ae0dbb3bb9cc46f4d9eb3704 Mon Sep 17 00:00:00 2001 From: Motohiro Takayama Date: Sun, 6 May 2012 11:10:57 -0700 Subject: [PATCH 3/5] s/gcc/closurecompiler/ --- syntax_checkers/javascript.vim | 2 +- syntax_checkers/javascript/{gcc.vim => closurecompiler.vim} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename syntax_checkers/javascript/{gcc.vim => closurecompiler.vim} (91%) diff --git a/syntax_checkers/javascript.vim b/syntax_checkers/javascript.vim index bcc8da67..61f9cd88 100644 --- a/syntax_checkers/javascript.vim +++ b/syntax_checkers/javascript.vim @@ -19,5 +19,5 @@ if exists("loaded_javascript_syntax_checker") endif let loaded_javascript_syntax_checker = 1 -let s:supported_checkers = ["gjslint", "jslint", "jsl", "jshint", "gcc"] +let s:supported_checkers = ["gjslint", "jslint", "jsl", "jshint", "closurecompiler"] call SyntasticLoadChecker(s:supported_checkers, 'javascript') diff --git a/syntax_checkers/javascript/gcc.vim b/syntax_checkers/javascript/closurecompiler.vim similarity index 91% rename from syntax_checkers/javascript/gcc.vim rename to syntax_checkers/javascript/closurecompiler.vim index 69cd8b5b..51b51238 100644 --- a/syntax_checkers/javascript/gcc.vim +++ b/syntax_checkers/javascript/closurecompiler.vim @@ -1,5 +1,5 @@ "============================================================================ -"File: gcc.vim +"File: closurecompiler.vim "Description: Javascript syntax checker - using Google Closure Compiler "Maintainer: Motohiro Takayama "License: This program is free software. It comes without any warranty, @@ -9,9 +9,9 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. "============================================================================ " -" To enable this plugin, edit the .vimc like this: +" To enable this plugin, edit the .vimrc like this: " -" let g:syntastic_javascript_checker = "gcc" +" let g:syntastic_javascript_checker = "closurecompiler" " " and set the path to the Google Closure Compiler: " From b94510fea334a5b104d76cbfdcef28dd43f8644a Mon Sep 17 00:00:00 2001 From: Motohiro Takayama Date: Mon, 7 May 2012 12:23:43 -0700 Subject: [PATCH 4/5] Do not check if the syntax_checker exists and is executable. Syntax checker name should be the filename of the syntax_checkers/*.vim. It can be any filename, and can be the name which does not exist in the PATH. --- plugin/syntastic.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index 21f368dd..ab2e45fc 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -613,7 +613,7 @@ function! SyntasticLoadChecker(checkers, ft) if exists(opt_name) let opt_val = {opt_name} - if index(a:checkers, opt_val) != -1 && executable(opt_val) + if index(a:checkers, opt_val) != -1 call s:LoadChecker(opt_val, a:ft) else echoerr &ft . " syntax not supported or not installed." From 0faf1bd47e69674d2b0090d535a97fae22e088f9 Mon Sep 17 00:00:00 2001 From: Motohiro Takayama Date: Mon, 7 May 2012 13:13:16 -0700 Subject: [PATCH 5/5] Added an option: g:syntastic_javascript_closure_compiler_file_list That variable specify the file which contains a list of filename that Closure Compiler processes at once. It can be useful for a project using 'require' statement like node.js. --- syntax_checkers/javascript/closurecompiler.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/syntax_checkers/javascript/closurecompiler.vim b/syntax_checkers/javascript/closurecompiler.vim index 51b51238..422a65fa 100644 --- a/syntax_checkers/javascript/closurecompiler.vim +++ b/syntax_checkers/javascript/closurecompiler.vim @@ -31,7 +31,13 @@ if !exists("g:syntastic_javascript_closure_compiler_path") endif function! SyntaxCheckers_javascript_GetLocList() - let makeprg = 'java -jar ' . g:syntastic_javascript_closure_compiler_path . ' ' . g:syntastic_javascript_closure_compiler_options . ' --js ' . shellescape(expand('%')) + if exists("g:syntastic_javascript_closure_compiler_file_list") + let file_list = join(readfile(g:syntastic_javascript_closure_compiler_file_list), ' ') + else + let file_list = shellescape(expand('%')) + endif + + let makeprg = 'java -jar ' . g:syntastic_javascript_closure_compiler_path . ' ' . g:syntastic_javascript_closure_compiler_options . ' --js ' . file_list let errorformat = '%-GOK,%E%f:%l: ERROR - %m,%Z%p^,%W%f:%l: WARNING - %m,%Z%p^' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction