Added option 'cwd' to SyntasticMake().
This commit is contained in:
parent
6574872b55
commit
da7002516b
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user