2011-12-28 16:12:45 -05:00
|
|
|
"============================================================================
|
|
|
|
"File: haxe.vim
|
|
|
|
"Description: Syntax checking plugin for syntastic.vim
|
2011-12-28 16:19:12 -05:00
|
|
|
"Maintainer: David Bernard <david.bernard.31 at gmail dot com>
|
2011-12-28 16:12:45 -05:00
|
|
|
"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.
|
|
|
|
"
|
|
|
|
"============================================================================
|
|
|
|
|
2013-01-27 15:08:30 -05:00
|
|
|
function! SyntaxCheckers_haxe_haxe_IsAvailable()
|
|
|
|
return executable('haxe')
|
|
|
|
endfunction
|
2011-12-28 16:12:45 -05:00
|
|
|
|
2012-01-06 13:20:04 -05:00
|
|
|
" s:FindInParent
|
2011-12-28 16:12:45 -05:00
|
|
|
" 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"
|
2012-01-06 13:20:04 -05:00
|
|
|
function! s:FindInParent(fln,flsrt,flstp)
|
2012-01-06 13:14:43 -05:00
|
|
|
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', '', '']
|
2011-12-28 16:12:45 -05:00
|
|
|
endfunction
|
|
|
|
|
2013-01-27 15:08:30 -05:00
|
|
|
function! SyntaxCheckers_haxe_haxe_GetLocList()
|
2012-01-06 13:20:04 -05:00
|
|
|
let [success, hxmldir, hxmlname] = s:FindInParent('*.hxml', expand('%:p:h'), '/')
|
2011-12-28 16:12:45 -05:00
|
|
|
if success == 'ok'
|
2012-01-06 13:14:43 -05:00
|
|
|
let makeprg = 'cd ' . hxmldir . '; haxe ' . hxmlname
|
|
|
|
let errorformat = '%E%f:%l: characters %c-%*[0-9] : %m'
|
|
|
|
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
2011-12-28 16:12:45 -05:00
|
|
|
else
|
2012-01-06 13:14:43 -05:00
|
|
|
return SyntasticMake({})
|
2011-12-28 16:12:45 -05:00
|
|
|
endif
|
|
|
|
endfunction
|
2013-01-27 15:08:30 -05:00
|
|
|
|
|
|
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
|
|
|
\ 'filetype': 'haxe',
|
|
|
|
\ 'name': 'haxe'})
|