update c_src (now with ffi)
[nit.git] / misc / vim / syntax_checkers / nit.vim
1 "============================================================================
2 "File:        nit.vim
3 "Description: Syntax checking plugin for syntastic.vim
4 "Maintainer:  Alexis Laferrière <alexis.laf@xymus.net>
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 "       g:syntastic_nitc specifies custom path to compiler
12 "       g:syntastic_nit_dir specifies the NIT_DIR env variable
13 "       g:syntastic_nit_args specifies extra arguments to call nitc
14 "       g:syntastic_nit_include_dirs lists directories to include, must be a list
15 "============================================================================
16 if exists("loaded_nit_syntax_checker")
17         finish
18 endif
19 let loaded_nit_syntax_checker = 1
20
21 " check if nitc is accessible
22 if exists('g:syntastic_nitc')
23         let s:nitc = g:syntastic_nitc
24 else
25         let s:nitc = "nitc"
26 endif
27
28 if !executable(s:nitc)
29         if exists('g:syntastic_nitc')
30                 echo "Syntastic for Nit error: Custom nitc cannot be found at: " . g:syntastic_nitc
31         endif
32         finish
33 endif
34
35 function! SyntaxCheckers_nit_GetLocList()
36         let makeprg = s:nitc . " --no-color --only-metamodel 2>&1 " . shellescape(expand("%"))
37
38         " custom NIT_DIR
39         if exists('g:syntastic_nit_dir')
40                 let makeprg = "NIT_DIR=" . g:syntastic_nit_dir . " " . makeprg
41         endif
42
43         " custom options for nit compiler
44         if exists('g:syntastic_nit_options')
45                 let makeprg .= " " . g:syntastic_nit_options
46         endif
47
48         " custom dirs to include for compiler
49         if exists('g:syntastic_nit_include_dirs')
50                 for d in g:syntastic_nit_include_dirs
51                         let makeprg .= " -I " . d
52                 endfor
53         end
54
55         " possible combinations of error messages
56         let ef_start = [ '%f:%l\,%c--%*[0-9]:', '%f:%l\,%c--%*[0-9]\,%*[0-9]:', '%f:%l\,%c:' ]
57         let ef_type = [ ' %tarning: ', '' ]
58
59         " generate errorformat from combinations
60         let errorformat = ""
61         for s in ef_start
62                 for t in ef_type
63                         let errorformat .= s . t . '%m,'
64                 endfor
65         endfor
66
67         return SyntasticMake({ 'makeprg': makeprg, 'errorformat':errorformat })
68 endfunction