aboutsummaryrefslogtreecommitdiff
path: root/vim/syntax_checkers/haxe.vim
blob: 22183ee598f188a0418162334bbabb6ff1858d6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"============================================================================
"File:        haxe.vim
"Description: Syntax checking plugin for syntastic.vim
"Maintainer:  David Bernard <david.bernard.31 at gmail dot com>
"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_haxe_syntax_checker")
    finish
endif
let loaded_haxe_syntax_checker = 1

"bail if the user doesn't have haxe installed
if !executable("haxe")
    finish
endif

" s:FindInParent
" find the file argument and returns the path to it.
" Starting with the current working dir, it walks up the parent folders
" until it finds the file, or it hits the stop dir.
" If it doesn't find it, it returns "Nothing"
function! s:FindInParent(fln,flsrt,flstp)
    let here = a:flsrt
    while ( strlen( here) > 0 )
        let p = split(globpath(here, a:fln), '\n')
        if len(p) > 0
            return ['ok', here, fnamemodify(p[0], ':p:t')]
        endif
        let fr = match(here, '/[^/]*$')
        if fr == -1
            break
        endif
        let here = strpart(here, 0, fr)
        if here == a:flstp
            break
        endif
    endwhile
    return ['fail', '', '']
endfunction

function! SyntaxCheckers_haxe_GetLocList()
    let [success, hxmldir, hxmlname] = s:FindInParent('*.hxml', expand('%:p:h'), '/')
    if success == 'ok'
        let makeprg = 'cd ' . hxmldir . '; haxe ' . hxmlname
        let errorformat = '%E%f:%l: characters %c-%*[0-9] : %m'
        return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
    else
        return SyntasticMake({})
    endif
endfunction