1 "============================================================================
3 "Description: Syntax checking plugin for syntastic.vim
4 "Maintainer: Török Edwin <edwintorok 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.
11 "============================================================================
13 " By default the camlp4o preprocessor is used to check the syntax of .ml, and .mli files,
14 " ocamllex is used to check .mll files and menhir is used to check .mly files.
15 " The output is all redirected to /dev/null, nothing is written to the disk.
17 " If your source code needs camlp4r then you can define this in your .vimrc:
19 " let g:syntastic_ocaml_camlp4r = 1
21 " If you used some syntax extensions, or you want to also typecheck the source
22 " code, then you can define this:
24 " let g:syntastic_ocaml_use_ocamlbuild = 1
26 " This will run ocamlbuild <name>.inferred.mli, so it will write to your _build
27 " directory (and possibly rebuild your myocamlbuild.ml plugin), only enable this
28 " if you are ok with that.
30 " If you are using syntax extensions / external libraries and have a properly
31 " set up _tags (and myocamlbuild.ml file) then it should just work
32 " to enable this flag and get syntax / type checks through syntastic.
34 " For best results your current directory should be the project root
35 " (same situation if you want useful output from :make).
37 if exists("loaded_ocaml_syntax_checker")
40 let loaded_ocaml_syntax_checker = 1
42 if exists('g:syntastic_ocaml_camlp4r') &&
43 \ g:syntastic_ocaml_camlp4r != 0
44 let s:ocamlpp="camlp4r"
46 let s:ocamlpp="camlp4o"
49 "bail if the user doesnt have the preprocessor
50 if !executable(s:ocamlpp)
54 function! SyntaxCheckers_ocaml_GetLocList()
55 if exists('g:syntastic_ocaml_use_ocamlbuild') &&
56 \ g:syntastic_ocaml_use_ocamlbuild != 0 &&
57 \ executable("ocamlbuild") &&
58 \ isdirectory('_build')
59 let makeprg = "ocamlbuild -quiet -no-log -tag annot,". s:ocamlpp. " -no-links -no-hygiene -no-sanitize ".
60 \ shellescape(expand('%:r')).".cmi"
62 let extension = expand('%:e')
63 if match(extension, 'mly') >= 0
64 " ocamlyacc output can't be redirected, so use menhir
65 if !executable("menhir")
68 let makeprg = "menhir --only-preprocess ".shellescape(expand('%')) . " >/dev/null"
69 elseif match(extension,'mll') >= 0
70 if !executable("ocamllex")
73 let makeprg = "ocamllex -q -o /dev/null ".shellescape(expand('%'))
75 let makeprg = "camlp4o -o /dev/null ".shellescape(expand('%'))
78 let errorformat = '%AFile "%f"\, line %l\, characters %c-%*\d:,'.
79 \ '%AFile "%f"\, line %l\, characters %c-%*\d (end at line %*\d\, character %*\d):,'.
80 \ '%AFile "%f"\, line %l\, character %c:,'.
81 \ '%AFile "%f"\, line %l\, character %c:%m,'.
82 \ '%-GPreprocessing error %.%#,'.
83 \ '%-GCommand exited %.%#,'.
84 \ '%C%tarning %n: %m,'.
88 return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })