diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index 5e84bd9e..176f50bd 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -19,7 +19,7 @@ if has('reltime') lockvar! g:syntastic_start endif -let g:syntastic_version = '3.4.0-92' +let g:syntastic_version = '3.4.0-93' lockvar g:syntastic_version " Sanity checks {{{1 @@ -408,7 +408,9 @@ endfunction " }}}2 " 'preprocess' - a function to be applied to the error file before parsing errors " 'postprocess' - a list of functions to be applied to the error list " 'cwd' - change directory to the given path before running the checker +" 'env' - environment variables to set before running the checker " 'returns' - a list of valid exit codes for the checker +" @vimlint(EVL102, 1, l:env_save) function! SyntasticMake(options) " {{{2 call syntastic#log#debug(g:SyntasticDebugTrace, 'SyntasticMake: called with options:', a:options) @@ -432,11 +434,31 @@ function! SyntasticMake(options) " {{{2 execute 'lcd ' . fnameescape(a:options['cwd']) endif + " set environment variables {{{3 + let env_save = {} + if has_key(a:options, 'env') && len(a:options['env']) + for key in keys(a:options['env']) + if key =~? '\m^[a-z_]\+$' + exec 'let env_save[' . string(key) . '] = $' . key + exec 'let $' . key . ' = ' . string(a:options['env'][key]) + endif + endfor + endif let $LC_MESSAGES = 'C' let $LC_ALL = '' + " }}}3 + let err_lines = split(system(a:options['makeprg']), "\n", 1) + + " restore environment variables {{{3 let $LC_ALL = old_lc_all let $LC_MESSAGES = old_lc_messages + if len(env_save) + for key in keys(env_save) + exec 'let $' . key . ' = ' . string(env_save[key]) + endfor + endif + " }}}3 call syntastic#log#debug(g:SyntasticDebugLoclist, 'checker output:', err_lines) @@ -497,6 +519,7 @@ function! SyntasticMake(options) " {{{2 return errors endfunction " }}}2 +" @vimlint(EVL102, 0, l:env_save) "return a string representing the state of buffer according to "g:syntastic_stl_format diff --git a/syntax_checkers/eruby/ruby.vim b/syntax_checkers/eruby/ruby.vim index 47378e0f..ea6b2f05 100644 --- a/syntax_checkers/eruby/ruby.vim +++ b/syntax_checkers/eruby/ruby.vim @@ -22,24 +22,14 @@ function! SyntaxCheckers_eruby_ruby_IsAvailable() dict if !exists('g:syntastic_eruby_ruby_exec') && exists('g:syntastic_ruby_exec') let g:syntastic_eruby_ruby_exec = g:syntastic_ruby_exec endif - let s:exe = self.getExec() - - if executable(s:exe) - let s:exe = syntastic#util#shescape(s:exe) - if !syntastic#util#isRunningWindows() - let s:exe = 'RUBYOPT= ' . s:exe - endif - return 1 - endif - - return 0 + return executable(self.getExec()) endfunction function! SyntaxCheckers_eruby_ruby_GetLocList() dict let fname = "'" . escape(expand('%'), "\\'") . "'" " TODO: encodings became useful in ruby 1.9 :) - if syntastic#util#versionIsAtLeast(syntastic#util#getVersion(s:exe . ' --version'), [1, 9]) + if syntastic#util#versionIsAtLeast(syntastic#util#getVersion(self.getExecEscaped(). ' --version'), [1, 9]) let enc = &fileencoding != '' ? &fileencoding : &encoding let encoding_spec = ', :encoding => "' . (enc ==? 'utf-8' ? 'UTF-8' : 'BINARY') . '"' else @@ -48,11 +38,11 @@ function! SyntaxCheckers_eruby_ruby_GetLocList() dict "gsub fixes issue #7, rails has it's own eruby syntax let makeprg = - \ s:exe . ' -rerb -e ' . + \ self.getExecEscaped() . ' -rerb -e ' . \ syntastic#util#shescape('puts ERB.new(File.read(' . \ fname . encoding_spec . \ ').gsub(''<%='',''<%''), nil, ''-'').src') . - \ ' | ' . s:exe . ' -c' + \ ' | ' . self.getExecEscaped() . ' -c' let errorformat = \ '%-GSyntax OK,'. @@ -61,9 +51,12 @@ function! SyntaxCheckers_eruby_ruby_GetLocList() dict \ '%Z%p^,'. \ '%-C%.%#' + let env = syntastic#util#isRunningWindows() ? {} : { 'RUBYOPT': '' } + return SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, + \ 'env': env, \ 'defaults': { 'bufnr': bufnr(""), 'vcol': 1 } }) endfunction diff --git a/syntax_checkers/html/tidy.vim b/syntax_checkers/html/tidy.vim index c13451c3..7dcf5223 100644 --- a/syntax_checkers/html/tidy.vim +++ b/syntax_checkers/html/tidy.vim @@ -186,9 +186,7 @@ function! s:Args() endfunction function! SyntaxCheckers_html_tidy_GetLocList() dict - let makeprg = self.makeprgBuild({ - \ 'args_after': s:Args(), - \ 'tail': '2>&1' }) + let makeprg = self.makeprgBuild({ 'args_after': s:Args() }) let errorformat = \ '%Wline %l column %v - Warning: %m,' . diff --git a/syntax_checkers/java/javac.vim b/syntax_checkers/java/javac.vim index ecf54725..2e138bea 100644 --- a/syntax_checkers/java/javac.vim +++ b/syntax_checkers/java/javac.vim @@ -399,8 +399,7 @@ function! SyntaxCheckers_java_javac_GetLocList() dict let makeprg = self.makeprgBuild({ \ 'args': javac_opts, - \ 'fname': syntastic#util#shescape(fname), - \ 'tail': '2>&1' }) + \ 'fname': syntastic#util#shescape(fname) }) " unashamedly stolen from *errorformat-javac* (quickfix.txt) and modified to include error types let errorformat = diff --git a/syntax_checkers/python/flake8.vim b/syntax_checkers/python/flake8.vim index ebc484f2..1e4f1c9b 100644 --- a/syntax_checkers/python/flake8.vim +++ b/syntax_checkers/python/flake8.vim @@ -19,8 +19,7 @@ function! SyntaxCheckers_python_flake8_GetHighlightRegex(item) endfunction function! SyntaxCheckers_python_flake8_GetLocList() dict - let makeprg = self.makeprgBuild({ - \ 'exe_before': (syntastic#util#isRunningWindows() ? '' : 'TERM=dumb') }) + let makeprg = self.makeprgBuild({}) let errorformat = \ '%E%f:%l: could not compile,%-Z%p^,' . @@ -28,9 +27,12 @@ function! SyntaxCheckers_python_flake8_GetLocList() dict \ '%A%f:%l: %t%n %m,' . \ '%-G%.%#' + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + let loclist = SyntasticMake({ \ 'makeprg': makeprg, - \ 'errorformat': errorformat }) + \ 'errorformat': errorformat, + \ 'env': env }) for e in loclist " E*** and W*** are pep8 errors diff --git a/syntax_checkers/python/frosted.vim b/syntax_checkers/python/frosted.vim index e96a8cc1..e1284e44 100644 --- a/syntax_checkers/python/frosted.vim +++ b/syntax_checkers/python/frosted.vim @@ -19,9 +19,7 @@ let s:save_cpo = &cpo set cpo&vim function! SyntaxCheckers_python_frosted_GetLocList() dict - let makeprg = self.makeprgBuild({ - \ 'exe_before': (syntastic#util#isRunningWindows() ? '' : 'TERM=dumb'), - \ 'args_after': '-vb' }) + let makeprg = self.makeprgBuild({ 'args_after': '-vb' }) let errorformat = \ '%f:%l:%c:%m,' . @@ -29,9 +27,12 @@ function! SyntaxCheckers_python_frosted_GetLocList() dict \ '%-Z%p^,' . \ '%-G%.%#' + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + let loclist = SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, + \ 'env': env, \ 'returns': [0, 1] }) for e in loclist diff --git a/syntax_checkers/python/pep257.vim b/syntax_checkers/python/pep257.vim index 60cf916e..d4b16575 100644 --- a/syntax_checkers/python/pep257.vim +++ b/syntax_checkers/python/pep257.vim @@ -19,8 +19,7 @@ function! SyntaxCheckers_python_pep257_GetLocList() dict \ self.getExecEscaped() . ' --version'), [0, 3]) endif - let makeprg = self.makeprgBuild({ - \ 'exe_before': (syntastic#util#isRunningWindows() ? '' : 'TERM=dumb') }) + let makeprg = self.makeprgBuild({}) if s:pep257_new let errorformat = @@ -33,9 +32,12 @@ function! SyntaxCheckers_python_pep257_GetLocList() dict \ '%+C %m' endif + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + let loclist = SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, + \ 'env': env, \ 'subtype': 'Style', \ 'preprocess': 'killEmpty', \ 'postprocess': ['compressWhitespace'] }) diff --git a/syntax_checkers/python/pep8.vim b/syntax_checkers/python/pep8.vim index 64c9e640..0f35c276 100644 --- a/syntax_checkers/python/pep8.vim +++ b/syntax_checkers/python/pep8.vim @@ -21,14 +21,16 @@ let s:save_cpo = &cpo set cpo&vim function! SyntaxCheckers_python_pep8_GetLocList() dict - let makeprg = self.makeprgBuild({ - \ 'exe_before': (syntastic#util#isRunningWindows() ? '' : 'TERM=dumb') }) + let makeprg = self.makeprgBuild({}) let errorformat = '%f:%l:%c: %m' + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + let loclist = SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, + \ 'env': env, \ 'subtype': 'Style' }) for e in loclist diff --git a/syntax_checkers/python/py3kwarn.vim b/syntax_checkers/python/py3kwarn.vim index 1a4465e0..69a3060f 100644 --- a/syntax_checkers/python/py3kwarn.vim +++ b/syntax_checkers/python/py3kwarn.vim @@ -14,14 +14,16 @@ let s:save_cpo = &cpo set cpo&vim function! SyntaxCheckers_python_py3kwarn_GetLocList() dict - let makeprg = self.makeprgBuild({ - \ 'exe_before': (syntastic#util#isRunningWindows() ? '' : 'TERM=dumb') }) + let makeprg = self.makeprgBuild({}) let errorformat = '%W%f:%l:%c: %m' + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + return SyntasticMake({ \ 'makeprg': makeprg, - \ 'errorformat': errorformat }) + \ 'errorformat': errorformat, + \ 'env': env }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/python/pyflakes.vim b/syntax_checkers/python/pyflakes.vim index 351eb206..530a275c 100644 --- a/syntax_checkers/python/pyflakes.vim +++ b/syntax_checkers/python/pyflakes.vim @@ -40,8 +40,7 @@ function! SyntaxCheckers_python_pyflakes_GetHighlightRegex(i) endfunction function! SyntaxCheckers_python_pyflakes_GetLocList() dict - let makeprg = self.makeprgBuild({ - \ 'exe_before': (syntastic#util#isRunningWindows() ? '' : 'TERM=dumb') }) + let makeprg = self.makeprgBuild({}) let errorformat = \ '%E%f:%l: could not compile,'. @@ -50,9 +49,12 @@ function! SyntaxCheckers_python_pyflakes_GetLocList() dict \ '%E%f:%l: %m,'. \ '%-G%.%#' + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + let loclist = SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, + \ 'env': env, \ 'defaults': {'text': "Syntax error"} }) for e in loclist diff --git a/syntax_checkers/python/pylama.vim b/syntax_checkers/python/pylama.vim index b8611814..01c0ab62 100644 --- a/syntax_checkers/python/pylama.vim +++ b/syntax_checkers/python/pylama.vim @@ -23,18 +23,19 @@ function! SyntaxCheckers_python_pylama_GetHighlightRegex(item) endfunction function! SyntaxCheckers_python_pylama_GetLocList() dict - let makeprg = self.makeprgBuild({ - \ 'exe_before': (syntastic#util#isRunningWindows() ? '' : 'TERM=dumb'), - \ 'args_after': '-f pep8' }) + let makeprg = self.makeprgBuild({ 'args_after': '-f pep8' }) " TODO: "WARNING:pylama:..." messages are probably a logging bug let errorformat = \ '%-GWARNING:pylama:%.%#,' . \ '%A%f:%l:%c: %m' + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + let loclist = SyntasticMake({ \ 'makeprg': makeprg, - \ 'errorformat': errorformat }) + \ 'errorformat': errorformat, + \ 'env': env }) " adjust for weirdness in each checker for e in loclist diff --git a/syntax_checkers/python/pylint.vim b/syntax_checkers/python/pylint.vim index 131ca482..88dff422 100644 --- a/syntax_checkers/python/pylint.vim +++ b/syntax_checkers/python/pylint.vim @@ -23,7 +23,6 @@ endfunction function! SyntaxCheckers_python_pylint_GetLocList() dict let makeprg = self.makeprgBuild({ - \ 'exe_before': (syntastic#util#isRunningWindows() ? '' : 'TERM=dumb'), \ 'args_after': (s:pylint_new ? '-f text --msg-template="{path}:{line}:{column}:{C}: [{symbol}] {msg}" -r n' : '-f parseable -r n -i y') }) let errorformat = @@ -33,9 +32,12 @@ function! SyntaxCheckers_python_pylint_GetLocList() dict \ '%-Z%p^%.%#,' . \ '%-G%.%#' + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + let loclist = SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, + \ 'env': env, \ 'returns': range(32) }) for e in loclist diff --git a/syntax_checkers/python/python.vim b/syntax_checkers/python/python.vim index e962065d..5023ee6c 100644 --- a/syntax_checkers/python/python.vim +++ b/syntax_checkers/python/python.vim @@ -26,15 +26,16 @@ function! SyntaxCheckers_python_python_IsAvailable() dict endfunction function! SyntaxCheckers_python_python_GetLocList() dict - let makeprg = self.makeprgBuild({ - \ 'exe_before': (syntastic#util#isRunningWindows() ? '' : 'TERM=dumb'), - \ 'exe': [self.getExec(), s:compiler] }) + let makeprg = self.makeprgBuild({ 'exe': [self.getExec(), s:compiler] }) let errorformat = '%E%f:%l:%c: %m' + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + return SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, + \ 'env': env, \ 'returns': [0] }) endfunction diff --git a/syntax_checkers/ruby/jruby.vim b/syntax_checkers/ruby/jruby.vim index 9dba591a..bf57b091 100644 --- a/syntax_checkers/ruby/jruby.vim +++ b/syntax_checkers/ruby/jruby.vim @@ -20,7 +20,6 @@ set cpo&vim function! SyntaxCheckers_ruby_jruby_GetLocList() dict let makeprg = self.makeprgBuild({ - \ 'exe_before': (syntastic#util#isRunningWindows() ? '' : 'RUBYOPT='), \ 'args': (syntastic#util#isRunningWindows() ? '-T1' : ''), \ 'args_after': '-W1 -c' }) @@ -33,9 +32,12 @@ function! SyntaxCheckers_ruby_jruby_GetLocList() dict \ '%W%f:%l: %m,'. \ '%-C%.%#' + let env = syntastic#util#isRunningWindows() ? {} : { 'RUBYOPT': '' } + return SyntasticMake({ \ 'makeprg': makeprg, - \ 'errorformat': errorformat }) + \ 'errorformat': errorformat, + \ 'env': env }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/ruby/macruby.vim b/syntax_checkers/ruby/macruby.vim index a5fc1c40..54c8365f 100644 --- a/syntax_checkers/ruby/macruby.vim +++ b/syntax_checkers/ruby/macruby.vim @@ -18,9 +18,7 @@ let s:save_cpo = &cpo set cpo&vim function! SyntaxCheckers_ruby_macruby_GetLocList() dict - let makeprg = self.makeprgBuild({ - \ 'exe_before': 'RUBYOPT=', - \ 'args_after': '-W1 -c' }) + let makeprg = self.makeprgBuild({ 'args_after': '-W1 -c' }) let errorformat = \ '%-GSyntax OK,'. @@ -31,9 +29,12 @@ function! SyntaxCheckers_ruby_macruby_GetLocList() dict \ '%W%f:%l: %m,'. \ '%-C%.%#' + let env = { 'RUBYOPT': '' } + return SyntasticMake({ \ 'makeprg': makeprg, - \ 'errorformat': errorformat }) + \ 'errorformat': errorformat, + \ 'env': env }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ diff --git a/syntax_checkers/ruby/mri.vim b/syntax_checkers/ruby/mri.vim index 08af1b45..e55c493d 100644 --- a/syntax_checkers/ruby/mri.vim +++ b/syntax_checkers/ruby/mri.vim @@ -35,9 +35,7 @@ function! SyntaxCheckers_ruby_mri_GetHighlightRegex(i) endfunction function! SyntaxCheckers_ruby_mri_GetLocList() dict - let makeprg = self.makeprgBuild({ - \ 'exe_before': (syntastic#util#isRunningWindows() ? '' : 'RUBYOPT='), - \ 'args_after': '-w -T1 -c' }) + let makeprg = self.makeprgBuild({ 'args_after': '-w -T1 -c' }) "this is a hack to filter out a repeated useless warning in rspec files "containing lines like @@ -62,9 +60,12 @@ function! SyntaxCheckers_ruby_mri_GetLocList() dict \ '%W%f:%l: %m,'. \ '%-C%.%#' + let env = syntastic#util#isRunningWindows() ? {} : { 'RUBYOPT': '' } + return SyntasticMake({ \ 'makeprg': makeprg, - \ 'errorformat': errorformat }) + \ 'errorformat': errorformat, + \ 'env': env }) endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({