diff options
author | w0rp <devw0rp@gmail.com> | 2021-05-27 22:03:39 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2021-05-27 22:03:46 +0100 |
commit | 1b08791228f5aca4545a3fba6699b29a003028fe (patch) | |
tree | 42cb78fe66f93100217ecb1230c269c26d58db1b /ale_linters/go | |
parent | a02a4f2811f810877f3c3859cca963f9578ff94a (diff) | |
download | ale-1b08791228f5aca4545a3fba6699b29a003028fe.zip |
Make staticcheck configurable with GOPATH detection
Diffstat (limited to 'ale_linters/go')
-rw-r--r-- | ale_linters/go/gopls.vim | 16 | ||||
-rw-r--r-- | ale_linters/go/staticcheck.vim | 10 |
2 files changed, 8 insertions, 18 deletions
diff --git a/ale_linters/go/gopls.vim b/ale_linters/go/gopls.vim index 23082e9b..80909830 100644 --- a/ale_linters/go/gopls.vim +++ b/ale_linters/go/gopls.vim @@ -7,20 +7,6 @@ call ale#Set('go_gopls_options', '--mode stdio') call ale#Set('go_gopls_init_options', {}) call ale#Set('go_gopls_use_global', get(g:, 'ale_use_global_executables', 0)) -function! s:GetGoPathExecutable(suffix) abort - let l:prefix = $GOPATH - - if !empty($GOPATH) - let l:prefix = $GOPATH - elseif has('win32') - let l:prefix = $USERPROFILE . '/go' - else - let l:prefix = $HOME . '/go' - endif - - return ale#path#Simplify(l:prefix . '/' . a:suffix) -endfunction - function! ale_linters#go#gopls#GetCommand(buffer) abort return ale#go#EnvString(a:buffer) \ . '%e' @@ -45,7 +31,7 @@ call ale#linter#Define('go', { \ 'name': 'gopls', \ 'lsp': 'stdio', \ 'executable': {b -> ale#path#FindExecutable(b, 'go_gopls', [ -\ s:GetGoPathExecutable('bin/gopls'), +\ ale#go#GetGoPathExecutable('bin/gopls'), \ ])}, \ 'command': function('ale_linters#go#gopls#GetCommand'), \ 'project_root': function('ale_linters#go#gopls#FindProjectRoot'), diff --git a/ale_linters/go/staticcheck.vim b/ale_linters/go/staticcheck.vim index 84e70d58..5dc88f1a 100644 --- a/ale_linters/go/staticcheck.vim +++ b/ale_linters/go/staticcheck.vim @@ -1,8 +1,10 @@ " Author: Ben Reedy <https://github.com/breed808> " Description: staticcheck for Go files +call ale#Set('go_staticcheck_executable', 'staticcheck') call ale#Set('go_staticcheck_options', '') call ale#Set('go_staticcheck_lint_package', 0) +call ale#Set('go_staticcheck_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#go#staticcheck#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'go_staticcheck_options') @@ -10,18 +12,20 @@ function! ale_linters#go#staticcheck#GetCommand(buffer) abort let l:env = ale#go#EnvString(a:buffer) if l:lint_package - return l:env . 'staticcheck' + return l:env . '%e' \ . (!empty(l:options) ? ' ' . l:options : '') . ' .' endif - return l:env . 'staticcheck' + return l:env . '%e' \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' %s:t' endfunction call ale#linter#Define('go', { \ 'name': 'staticcheck', -\ 'executable': 'staticcheck', +\ 'executable': {b -> ale#path#FindExecutable(b, 'go_staticcheck', [ +\ ale#go#GetGoPathExecutable('bin/staticcheck'), +\ ])}, \ 'cwd': '%s:h', \ 'command': function('ale_linters#go#staticcheck#GetCommand'), \ 'callback': 'ale#handlers#go#Handler', |