misc: correctly handles warnings in syntastic Nit syntax checker
[nit.git] / misc / syntastic / 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 if exists("loaded_nit_syntax_checker")
12         finish
13 endif
14 let loaded_nit_syntax_checker = 1
15
16 " check if nitc is accessible
17 if !executable("nitc")
18         finish
19 endif
20
21 function! SyntaxCheckers_nit_GetLocList()
22         let makeprg = "nitc --no-color --only-metamodel 2>&1 " . shellescape(expand("%"))
23         " possible combinations of error messages
24         let ef_start = [ '%f:%l\,%c--%*[0-9]:', '%f:%l\,%c--%*[0-9]\,%*[0-9]:', '%f:%l\,%c:' ]
25         let ef_type = [ ' %tarning: ', ' %trror: ', ' Syntax %trror: ' ]
26
27         " generate errorformat from combinations
28         let errorformat = ""
29         for s in ef_start
30                 for t in ef_type
31                         let errorformat .= s . t . '%m,'
32                 endfor
33         endfor
34
35         return SyntasticMake({ 'makeprg': makeprg, 'errorformat':errorformat })
36 endfunction