mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-03 18:14:01 +08:00
Merge pull request #2430 from eliath/master
Support $GO111MODULE with Go tooling
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user