From da7002516b2460fb626f6571f387cf1853364b59 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Tue, 11 Jun 2013 21:36:44 +0300 Subject: [PATCH] Added option 'cwd' to SyntasticMake(). --- plugin/syntastic.vim | 10 ++++++++++ syntax_checkers/go/go.vim | 11 ++--------- syntax_checkers/go/govet.vim | 18 +++++++----------- syntax_checkers/haxe/haxe.vim | 15 ++++++++++++--- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index 213df926..187a4912 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -315,6 +315,7 @@ endfunction " 'defaults' - a dict containing default values for the returned errors " 'subtype' - all errors will be assigned the given subtype " 'postprocess' - a list of functions to be applied to the error list +" 'cwd' - change directory to the given path before running the checker function! SyntasticMake(options) call syntastic#util#debug('SyntasticMake: called with options: '. string(a:options)) @@ -323,6 +324,7 @@ function! SyntasticMake(options) let old_shellpipe = &shellpipe let old_shell = &shell let old_errorformat = &l:errorformat + let old_cwd = getcwd() let old_lc_all = $LC_ALL if s:OSSupportsShellpipeHack() @@ -340,12 +342,20 @@ function! SyntasticMake(options) let &l:errorformat = a:options['errorformat'] endif + if has_key(a:options, 'cwd') + exec 'lcd ' . fnameescape(a:options['cwd']) + endif + let $LC_ALL = 'C' silent lmake! let $LC_ALL = old_lc_all let errors = getloclist(0) + if has_key(a:options, 'cwd') + exec 'lcd ' . fnameescape(old_cwd) + endif + call setloclist(0, old_loclist) let &l:makeprg = old_makeprg let &l:errorformat = old_errorformat diff --git a/syntax_checkers/go/go.vim b/syntax_checkers/go/go.vim index 8d023f30..e389012a 100644 --- a/syntax_checkers/go/go.vim +++ b/syntax_checkers/go/go.vim @@ -59,21 +59,14 @@ function! SyntaxCheckers_go_go_GetLocList() " The go compiler needs to either be run with an import path as an " argument or directly from the package directory. Since figuring out - " the poper import path is fickle, just pushd/popd to the package. - let popd = getcwd() - let pushd = expand('%:p:h') - - " pushd - exec 'lcd ' . fnameescape(pushd) + " the proper import path is fickle, just cwd to the package. let errors = SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, + \ 'cwd': expand('%:p:h'), \ 'defaults': {'type': 'e'} }) - " popd - exec 'lcd ' . fnameescape(popd) - return errors endfunction diff --git a/syntax_checkers/go/govet.vim b/syntax_checkers/go/govet.vim index b4f00682..4b1d7efb 100644 --- a/syntax_checkers/go/govet.vim +++ b/syntax_checkers/go/govet.vim @@ -22,19 +22,15 @@ function! SyntaxCheckers_go_govet_GetLocList() let makeprg = 'go vet' let errorformat = '%Evet: %.%\+: %f:%l:%c: %m,%W%f:%l: %m,%-G%.%#' - " The go tool needs to either be run with an import path as an + " The go compiler needs to either be run with an import path as an " argument or directly from the package directory. Since figuring out - " the poper import path is fickle, just pushd/popd to the package. - let popd = getcwd() - let pushd = expand('%:p:h') - " - " pushd - exec 'lcd ' . fnameescape(pushd) + " the proper import path is fickle, just cwd to the package. - let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'type': 'w'} }) - - " popd - exec 'lcd ' . fnameescape(popd) + let errors = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'cwd': expand('%:p:h'), + \ 'defaults': {'type': 'w'} }) return errors endfunction diff --git a/syntax_checkers/haxe/haxe.vim b/syntax_checkers/haxe/haxe.vim index 97095eec..204eeae5 100644 --- a/syntax_checkers/haxe/haxe.vim +++ b/syntax_checkers/haxe/haxe.vim @@ -46,11 +46,20 @@ endfunction function! SyntaxCheckers_haxe_haxe_GetLocList() let [success, hxmldir, hxmlname] = s:FindInParent('*.hxml', expand('%:p:h'), '/') if success == 'ok' - let makeprg = 'cd ' . hxmldir . '; haxe ' . hxmlname + let makeprg = syntastic#makeprg#build({ + \ 'exe': 'haxe', + \ 'fname': shellescape(fnameescape(hxmlname)), + \ 'filetype': 'haxe', + \ 'subchecker': 'haxe' }) + let errorformat = '%E%f:%l: characters %c-%*[0-9] : %m' - return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'cwd': hxmldir }) else - return SyntasticMake({}) + return [] endif endfunction