From d5cee024e920b40e7f7f3eb4287a81495d07ea10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20Edwin?= Date: Fri, 13 Jan 2012 14:00:53 +0200 Subject: [PATCH 1/3] add OCaml syntax checker --- syntax_checkers/ocaml.vim | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 syntax_checkers/ocaml.vim diff --git a/syntax_checkers/ocaml.vim b/syntax_checkers/ocaml.vim new file mode 100644 index 00000000..8764ac1d --- /dev/null +++ b/syntax_checkers/ocaml.vim @@ -0,0 +1,49 @@ +"============================================================================ +"File: ocaml.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Török Edwin +"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_ocaml_syntax_checker") + finish +endif +let loaded_ocaml_syntax_checker = 1 + +"bail if the user doesnt have camlp4o installed +if !executable("camlp4o") + finish +endif + +function! SyntaxCheckers_ocaml_GetLocList() + let extension = expand('%:e') + if match(extension, 'mly') >= 0 + " ocamlyacc output can't be redirected, so use menhir + if !executable("menhir") + return [] + endif + let makeprg = "menhir --only-preprocess ".shellescape(expand('%')) . " >/dev/null" + elseif match(extension,'mll') >= 0 + if !executable("ocamllex") + return [] + endif + let makeprg = "ocamllex -q -o /dev/null ".shellescape(expand('%')) + else + let makeprg = "camlp4o -o /dev/null ".shellescape(expand('%')) + endif + let errorformat = '%EFile "%f"\, line %l\, characters %c-%*\d:,'. + \ '%EFile "%f"\, line %l\, characters %c-%*\d (end at line %*\d\, character %*\d):,'. + \ '%EFile "%f"\, line %l\, character %c:,'. + \ '%EFile "%f"\, line %l\, character %c:%m,'. + \ '%C%m' + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endfunction + +function! SyntaxCheckers_locaml_GetLocList() + return SyntaxCheckers_ocaml_GetLocList() +endfunction From f7072dd0ff1008e2aba3df7b08b63920e3462e51 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 13 Jan 2012 12:11:43 +0000 Subject: [PATCH 2/3] ocaml: fix mixed indenting indent with spaces only, and consistently use 4 spaces --- syntax_checkers/ocaml.vim | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/syntax_checkers/ocaml.vim b/syntax_checkers/ocaml.vim index 8764ac1d..27e3eea3 100644 --- a/syntax_checkers/ocaml.vim +++ b/syntax_checkers/ocaml.vim @@ -22,24 +22,24 @@ endif function! SyntaxCheckers_ocaml_GetLocList() let extension = expand('%:e') if match(extension, 'mly') >= 0 - " ocamlyacc output can't be redirected, so use menhir - if !executable("menhir") - return [] - endif - let makeprg = "menhir --only-preprocess ".shellescape(expand('%')) . " >/dev/null" + " ocamlyacc output can't be redirected, so use menhir + if !executable("menhir") + return [] + endif + let makeprg = "menhir --only-preprocess ".shellescape(expand('%')) . " >/dev/null" elseif match(extension,'mll') >= 0 - if !executable("ocamllex") - return [] - endif - let makeprg = "ocamllex -q -o /dev/null ".shellescape(expand('%')) + if !executable("ocamllex") + return [] + endif + let makeprg = "ocamllex -q -o /dev/null ".shellescape(expand('%')) else - let makeprg = "camlp4o -o /dev/null ".shellescape(expand('%')) + let makeprg = "camlp4o -o /dev/null ".shellescape(expand('%')) endif let errorformat = '%EFile "%f"\, line %l\, characters %c-%*\d:,'. - \ '%EFile "%f"\, line %l\, characters %c-%*\d (end at line %*\d\, character %*\d):,'. - \ '%EFile "%f"\, line %l\, character %c:,'. - \ '%EFile "%f"\, line %l\, character %c:%m,'. - \ '%C%m' + \ '%EFile "%f"\, line %l\, characters %c-%*\d (end at line %*\d\, character %*\d):,'. + \ '%EFile "%f"\, line %l\, character %c:,'. + \ '%EFile "%f"\, line %l\, character %c:%m,'. + \ '%C%m' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction From 10e6fe51f070ee1e3c96a930400afbbccc694d77 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Fri, 13 Jan 2012 12:14:58 +0000 Subject: [PATCH 3/3] add locaml checker and make it alias ocaml Move the locaml->lcaml alias function out of the ocaml checker as this code wont be loaded for locaml files - only syntax checkers for filetype that are in use get sourced --- syntax_checkers/locaml.vim | 26 ++++++++++++++++++++++++++ syntax_checkers/ocaml.vim | 4 ---- 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 syntax_checkers/locaml.vim diff --git a/syntax_checkers/locaml.vim b/syntax_checkers/locaml.vim new file mode 100644 index 00000000..02b1280e --- /dev/null +++ b/syntax_checkers/locaml.vim @@ -0,0 +1,26 @@ +"============================================================================ +"File: locaml.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Török Edwin +"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_locaml_syntax_checker") + finish +endif +let loaded_locaml_syntax_checker = 1 + +"bail if the user doesnt have camlp4o installed +if !executable("camlp4o") + finish +endif + +runtime syntax_checkers/ocaml.vim + +function! SyntaxCheckers_locaml_GetLocList() + return SyntaxCheckers_ocaml_GetLocList() +endfunction diff --git a/syntax_checkers/ocaml.vim b/syntax_checkers/ocaml.vim index 27e3eea3..0ebe30cb 100644 --- a/syntax_checkers/ocaml.vim +++ b/syntax_checkers/ocaml.vim @@ -43,7 +43,3 @@ function! SyntaxCheckers_ocaml_GetLocList() return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction - -function! SyntaxCheckers_locaml_GetLocList() - return SyntaxCheckers_ocaml_GetLocList() -endfunction