From 33b3331b0499e502f01730af60fb0e9b5a30951f Mon Sep 17 00:00:00 2001 From: w0rp Date: Sun, 4 Feb 2018 13:55:09 +0000 Subject: #1206 Add support for setting options for gobuild, and escape paths better --- ale_linters/go/gobuild.vim | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'ale_linters/go/gobuild.vim') diff --git a/ale_linters/go/gobuild.vim b/ale_linters/go/gobuild.vim index 783b9e0a..068877a3 100644 --- a/ale_linters/go/gobuild.vim +++ b/ale_linters/go/gobuild.vim @@ -1,9 +1,14 @@ " Author: Joshua Rubin , Ben Reedy , " Jeff Willette " Description: go build for Go files - " inspired by work from dzhou121 +call ale#Set('go_gobuild_options', '') + +function! ale_linters#go#gobuild#ResetEnv() abort + unlet! s:go_env +endfunction + function! ale_linters#go#gobuild#GoEnv(buffer) abort if exists('s:go_env') return '' @@ -13,6 +18,8 @@ function! ale_linters#go#gobuild#GoEnv(buffer) abort endfunction function! ale_linters#go#gobuild#GetCommand(buffer, goenv_output) abort + let l:options = ale#Var(a:buffer, 'go_gobuild_options') + if !exists('s:go_env') let s:go_env = { \ 'GOPATH': a:goenv_output[0], @@ -20,10 +27,16 @@ function! ale_linters#go#gobuild#GetCommand(buffer, goenv_output) abort \} endif + let l:gopath_env_command = has('win32') + \ ? 'set GOPATH=' . ale#Escape(s:go_env.GOPATH) . ' && ' + \ : 'GOPATH=' . ale#Escape(s:go_env.GOPATH) . ' ' + " Run go test in local directory with relative path - return 'GOPATH=' . s:go_env.GOPATH - \ . ' cd ' . fnamemodify(bufname(a:buffer), ':.:h') - \ . ' && go test -c -o /dev/null ./' + return l:gopath_env_command + \ . ale#path#BufferCdString(a:buffer) + \ . 'go test' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -c -o /dev/null ./' endfunction function! ale_linters#go#gobuild#GetMatches(lines) abort -- cgit v1.2.3