summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2019-07-30 21:17:20 +0100
committerGitHub <noreply@github.com>2019-07-30 21:17:20 +0100
commit3ae01ba24967a37e5a41626673422be53e188026 (patch)
treeb68094ab353b74b998de86f003631401f5ff0d85 /autoload
parent8f5ecf01200f82d12d452992a92c23fcf9e0f0e8 (diff)
parent49db8210f68637a2af14b21940f3cbbaf7361047 (diff)
downloadale-3ae01ba24967a37e5a41626673422be53e188026.zip
Merge pull request #2430 from eliath/master
Support $GO111MODULE with Go tooling
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fixers/gofmt.vim3
-rw-r--r--autoload/ale/fixers/goimports.vim3
-rw-r--r--autoload/ale/fixers/gomod.vim3
-rw-r--r--autoload/ale/go.vim17
4 files changed, 23 insertions, 3 deletions
diff --git a/autoload/ale/fixers/gofmt.vim b/autoload/ale/fixers/gofmt.vim
index 66b67a9e..d5a539b9 100644
--- a/autoload/ale/fixers/gofmt.vim
+++ b/autoload/ale/fixers/gofmt.vim
@@ -7,9 +7,10 @@ call ale#Set('go_gofmt_options', '')
function! ale#fixers#gofmt#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'go_gofmt_executable')
let l:options = ale#Var(a:buffer, 'go_gofmt_options')
+ let l:env = ale#go#EnvString(a:buffer)
return {
- \ 'command': ale#Escape(l:executable)
+ \ 'command': l:env . ale#Escape(l:executable)
\ . ' -l -w'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ' %t',
diff --git a/autoload/ale/fixers/goimports.vim b/autoload/ale/fixers/goimports.vim
index 783d0206..65f0fd98 100644
--- a/autoload/ale/fixers/goimports.vim
+++ b/autoload/ale/fixers/goimports.vim
@@ -7,13 +7,14 @@ call ale#Set('go_goimports_options', '')
function! ale#fixers#goimports#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'go_goimports_executable')
let l:options = ale#Var(a:buffer, 'go_goimports_options')
+ let l:env = ale#go#EnvString(a:buffer)
if !executable(l:executable)
return 0
endif
return {
- \ 'command': ale#Escape(l:executable)
+ \ 'command': l:env . ale#Escape(l:executable)
\ . ' -l -w -srcdir %s'
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ' %t',
diff --git a/autoload/ale/fixers/gomod.vim b/autoload/ale/fixers/gomod.vim
index 68895f9b..ee8c46c9 100644
--- a/autoload/ale/fixers/gomod.vim
+++ b/autoload/ale/fixers/gomod.vim
@@ -2,9 +2,10 @@ call ale#Set('go_go_executable', 'go')
function! ale#fixers#gomod#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'go_go_executable')
+ let l:env = ale#go#EnvString(a:buffer)
return {
- \ 'command': ale#Escape(l:executable) . ' mod edit -fmt %t',
+ \ 'command': l:env . ale#Escape(l:executable) . ' mod edit -fmt %t',
\ 'read_temporary_file': 1,
\}
endfunction
diff --git a/autoload/ale/go.vim b/autoload/ale/go.vim
index cd7d9503..4a21e596 100644
--- a/autoload/ale/go.vim
+++ b/autoload/ale/go.vim
@@ -25,3 +25,20 @@ function! ale#go#FindProjectRoot(buffer) abort
return ''
endfunction
+
+
+call ale#Set('go_go111module', '')
+
+" Return a string setting Go-specific environment variables
+function! ale#go#EnvString(buffer) abort
+ let l:env = ''
+
+ " GO111MODULE - turn go modules behavior on/off
+ let l:go111module = ale#Var(a:buffer, 'go_go111module')
+
+ if !empty(l:go111module)
+ let l:env = ale#Env('GO111MODULE', l:go111module) . l:env
+ endif
+
+ return l:env
+endfunction