From 2302f12367006ee35cbeab729425640a550a44bc Mon Sep 17 00:00:00 2001 From: Zhao Cai Date: Fri, 9 Dec 2011 10:32:39 -0500 Subject: [PATCH 1/2] add applescript syntax_checker --- syntax_checkers/applescript.vim | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 syntax_checkers/applescript.vim diff --git a/syntax_checkers/applescript.vim b/syntax_checkers/applescript.vim new file mode 100644 index 00000000..491a08fa --- /dev/null +++ b/syntax_checkers/applescript.vim @@ -0,0 +1,53 @@ +"============================================================================== +" FileName: applescript.vim +" Desc: Syntax checking plugin for syntastic.vim +" Author: Zhao Cai +" Email: caizhaoff@gmail.com +" Version: 0.1 +" Date Created: Thu 09 Sep 2011 10:30:09 AM EST +" Last Modified: Fri 09 Dec 2011 10:32:04 AM EST +" +" History: 0.1 - working, but it will run the script everytime to check +" syntax. Should use osacompile but strangely it does not give +" errors. +" +" 0.1.1 - switch to osacompile, it gives less errors compared +" with osascript. +" +" 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. +" +"============================================================================ + +if exists("loaded_applescript_syntax_checker") + finish +endif +let loaded_applescript_syntax_checker = 1 + +"bail if the user doesnt have osacompile installed +if !executable("osacompile") + finish +endif + +if !exists("g:syntastic_applescript_tempfile") + echohl WarningMsg + echom "set g:syntastic_applescript_tempfile = /path/to/file.scpt is recommanded." + echohl NONE + + let s:osacompile = 'osacompile -o ' . shellescape(expand('%:p:r') . '.scpt') +else + if &verbose > 1 && filereadable(g:syntastic_applescript_tempfile) + echom g:syntastic_applescript_tempfile . ' exists. Make sure it is OK to overwrite!' + endif + let s:osacompile = 'osacompile -o ' . g:syntastic_applescript_tempfile +endif + +function! SyntaxCheckers_applescript_GetLocList() + let makeprg = s:osacompile .' '. shellescape(expand('%')) + let errorformat = '%f:%l:%m' + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endfunction From 6a7529713bd2d3b7ab685743538fbdca58a0a334 Mon Sep 17 00:00:00 2001 From: Zhao Cai Date: Fri, 9 Dec 2011 13:11:45 -0500 Subject: [PATCH 2/2] 0.2.1 - remove g:syntastic_applescript_tempfile. use tempname() instead. --- syntax_checkers/applescript.vim | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/syntax_checkers/applescript.vim b/syntax_checkers/applescript.vim index 491a08fa..eb7a6f28 100644 --- a/syntax_checkers/applescript.vim +++ b/syntax_checkers/applescript.vim @@ -3,17 +3,20 @@ " Desc: Syntax checking plugin for syntastic.vim " Author: Zhao Cai " Email: caizhaoff@gmail.com -" Version: 0.1 +" Version: 0.2.1 " Date Created: Thu 09 Sep 2011 10:30:09 AM EST -" Last Modified: Fri 09 Dec 2011 10:32:04 AM EST +" Last Modified: Fri 09 Dec 2011 01:10:24 PM EST " -" History: 0.1 - working, but it will run the script everytime to check +" History: 0.1.0 - working, but it will run the script everytime to check " syntax. Should use osacompile but strangely it does not give " errors. " -" 0.1.1 - switch to osacompile, it gives less errors compared +" 0.2.0 - switch to osacompile, it gives less errors compared " with osascript. " +" 0.2.1 - remove g:syntastic_applescript_tempfile. use +" tempname() instead. +" " 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 @@ -32,21 +35,8 @@ if !executable("osacompile") finish endif -if !exists("g:syntastic_applescript_tempfile") - echohl WarningMsg - echom "set g:syntastic_applescript_tempfile = /path/to/file.scpt is recommanded." - echohl NONE - - let s:osacompile = 'osacompile -o ' . shellescape(expand('%:p:r') . '.scpt') -else - if &verbose > 1 && filereadable(g:syntastic_applescript_tempfile) - echom g:syntastic_applescript_tempfile . ' exists. Make sure it is OK to overwrite!' - endif - let s:osacompile = 'osacompile -o ' . g:syntastic_applescript_tempfile -endif - function! SyntaxCheckers_applescript_GetLocList() - let makeprg = s:osacompile .' '. shellescape(expand('%')) + let makeprg = 'osacompile -o ' . tempname() . '.scpt '. shellescape(expand('%')) let errorformat = '%f:%l:%m' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })