From c60e440d006f81e5df0ed45eade4451cc2efaa85 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Thu, 15 Jan 2015 17:51:15 +0200 Subject: [PATCH] Go checker: more contortions around "go_go_build_args" and "go_go_test_args". --- autoload/syntastic/util.vim | 11 +++++++++++ plugin/syntastic/checker.vim | 16 +++------------- syntax_checkers/go/go.vim | 8 ++++++-- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/autoload/syntastic/util.vim b/autoload/syntastic/util.vim index 233c697c..971d5096 100644 --- a/autoload/syntastic/util.vim +++ b/autoload/syntastic/util.vim @@ -264,6 +264,17 @@ function! syntastic#util#shexpand(string, ...) " {{{2 return syntastic#util#shescape(a:0 ? expand(a:string, a:1) : expand(a:string, 1)) endfunction " }}}2 +" Escape arguments +function! syntastic#util#argsescape(opt) " {{{2 + if type(a:opt) == type('') && a:opt != '' + return [a:opt] + elseif type(a:opt) == type([]) + return map(copy(a:opt), 'syntastic#util#shescape(v:val)') + endif + + return [] +endfunction " }}}2 + " decode XML entities function! syntastic#util#decodeXMLEntities(string) " {{{2 let str = a:string diff --git a/plugin/syntastic/checker.vim b/plugin/syntastic/checker.vim index ee66ba22..9211e02a 100644 --- a/plugin/syntastic/checker.vim +++ b/plugin/syntastic/checker.vim @@ -162,23 +162,13 @@ endfunction " }}}2 function! g:SyntasticChecker._getOpt(opts, basename, name, default) " {{{2 let ret = [] - call extend( ret, self._shescape(get(a:opts, a:name . '_before', '')) ) - call extend( ret, self._shescape(syntastic#util#var( a:basename . a:name, get(a:opts, a:name, a:default) )) ) - call extend( ret, self._shescape(get(a:opts, a:name . '_after', '')) ) + call extend( ret, syntastic#util#argsescape(get(a:opts, a:name . '_before', '')) ) + call extend( ret, syntastic#util#argsescape(syntastic#util#var( a:basename . a:name, get(a:opts, a:name, a:default) )) ) + call extend( ret, syntastic#util#argsescape(get(a:opts, a:name . '_after', '')) ) return ret endfunction " }}}2 -function! g:SyntasticChecker._shescape(opt) " {{{2 - if type(a:opt) == type('') && a:opt != '' - return [a:opt] - elseif type(a:opt) == type([]) - return map(copy(a:opt), 'syntastic#util#shescape(v:val)') - endif - - return [] -endfunction " }}}2 - " }}}1 " Private functions {{{1 diff --git a/syntax_checkers/go/go.vim b/syntax_checkers/go/go.vim index ccd737f6..37c297a0 100644 --- a/syntax_checkers/go/go.vim +++ b/syntax_checkers/go/go.vim @@ -51,12 +51,16 @@ function! SyntaxCheckers_go_go_GetLocList() dict " compiled by `go build`, therefore `go test` must be called for those. if match(expand('%', 1), '\m_test\.go$') == -1 let opts = syntastic#util#var('go_go_build_args') - let opts = opts != '' ? syntastic#util#shescape(opts) : '' + if type(opts) != type('') || opts != '' + let opts = join(syntastic#util#argsescape(opts)) + endif let makeprg = self.getExec() . ' build ' . opts . ' ' . syntastic#c#NullOutput() let cleanup = 0 else let opts = syntastic#util#var('go_go_test_args') - let opts = opts != '' ? syntastic#util#shescape(opts) : '' + if type(opts) != type('') || opts != '' + let opts = join(syntastic#util#argsescape(opts)) + endif let makeprg = self.getExec() . ' test -c ' . opts . ' ' . syntastic#c#NullOutput() let cleanup = 1 endif