diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index 8fd41c29..bd3cdf1e 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -25,7 +25,7 @@ if !exists("g:syntastic_always_populate_loc_list") endif if !exists("g:syntastic_auto_jump") - let syntastic_auto_jump=0 + let g:syntastic_auto_jump = 0 endif if !exists("g:syntastic_quiet_warnings") diff --git a/syntax_checkers/haxe/haxe.vim b/syntax_checkers/haxe/haxe.vim index 204eeae5..fd9262c4 100644 --- a/syntax_checkers/haxe/haxe.vim +++ b/syntax_checkers/haxe/haxe.vim @@ -19,36 +19,42 @@ function! SyntaxCheckers_haxe_haxe_IsAvailable() return executable('haxe') endfunction -" 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 +" start in directory a:where and walk up the parent folders until it +" finds a file matching a:what; return path to that file +function! s:FindInParent(what, where) + let here = fnamemodify(a:where, ':p') + + while !empty(here) + let p = split(globpath(here, a:what), '\n') + + if !empty(p) + return fnamemodify(p[0], ':p') + elseif here == '/' break endif + + " we use ':h:h' rather than ':h' since ':p' adds a trailing '/' + " if 'here' is a directory + let here = fnamemodify(here, ':p:h:h') endwhile - return ['fail', '', ''] + + return '' endfunction function! SyntaxCheckers_haxe_haxe_GetLocList() - let [success, hxmldir, hxmlname] = s:FindInParent('*.hxml', expand('%:p:h'), '/') - if success == 'ok' + if exists('b:vaxe_hxml') + let hxml = b:vaxe_hxml + elseif exists('g:vaxe_hxml') + let hxml = g:vaxe_hxml + else + let hxml = s:FindInParent('*.hxml', expand('%:p:h')) + endif + let hxml = fnamemodify(hxml, ':p') + + if !empty(hxml) let makeprg = syntastic#makeprg#build({ \ 'exe': 'haxe', - \ 'fname': shellescape(fnameescape(hxmlname)), + \ 'fname': shellescape(fnameescape(fnamemodify(hxml, ':t'))), \ 'filetype': 'haxe', \ 'subchecker': 'haxe' }) @@ -57,10 +63,10 @@ function! SyntaxCheckers_haxe_haxe_GetLocList() return SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, - \ 'cwd': hxmldir }) - else - return [] + \ 'cwd': fnamemodify(hxml, ':h') }) endif + + return [] endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({