]> git.r.bdr.sh - rbdr/dotfiles/blob - vim/syntax_checkers/haxe.vim
22183ee598f188a0418162334bbabb6ff1858d6d
[rbdr/dotfiles] / vim / syntax_checkers / haxe.vim
1 "============================================================================
2 "File: haxe.vim
3 "Description: Syntax checking plugin for syntastic.vim
4 "Maintainer: David Bernard <david.bernard.31 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.
10 "
11 "============================================================================
12 if exists("loaded_haxe_syntax_checker")
13 finish
14 endif
15 let loaded_haxe_syntax_checker = 1
16
17 "bail if the user doesn't have haxe installed
18 if !executable("haxe")
19 finish
20 endif
21
22 " s:FindInParent
23 " find the file argument and returns the path to it.
24 " Starting with the current working dir, it walks up the parent folders
25 " until it finds the file, or it hits the stop dir.
26 " If it doesn't find it, it returns "Nothing"
27 function! s:FindInParent(fln,flsrt,flstp)
28 let here = a:flsrt
29 while ( strlen( here) > 0 )
30 let p = split(globpath(here, a:fln), '\n')
31 if len(p) > 0
32 return ['ok', here, fnamemodify(p[0], ':p:t')]
33 endif
34 let fr = match(here, '/[^/]*$')
35 if fr == -1
36 break
37 endif
38 let here = strpart(here, 0, fr)
39 if here == a:flstp
40 break
41 endif
42 endwhile
43 return ['fail', '', '']
44 endfunction
45
46 function! SyntaxCheckers_haxe_GetLocList()
47 let [success, hxmldir, hxmlname] = s:FindInParent('*.hxml', expand('%:p:h'), '/')
48 if success == 'ok'
49 let makeprg = 'cd ' . hxmldir . '; haxe ' . hxmlname
50 let errorformat = '%E%f:%l: characters %c-%*[0-9] : %m'
51 return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
52 else
53 return SyntasticMake({})
54 endif
55 endfunction