mirror of
https://github.com/dense-analysis/ale.git
synced 2026-05-18 06:19:49 +08:00
Enable gopls by default with GOPATH detection
This commit is contained in:
@@ -5,6 +5,21 @@
|
||||
call ale#Set('go_gopls_executable', 'gopls')
|
||||
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)
|
||||
@@ -29,7 +44,9 @@ endfunction
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'gopls',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#Var(b, 'go_gopls_executable')},
|
||||
\ 'executable': {b -> ale#path#FindExecutable(b, 'go_gopls', [
|
||||
\ s:GetGoPathExecutable('bin/gopls'),
|
||||
\ ])},
|
||||
\ 'command': function('ale_linters#go#gopls#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#go#gopls#FindProjectRoot'),
|
||||
\ 'initialization_options': {b -> ale#Var(b, 'go_gopls_init_options')},
|
||||
|
||||
Reference in New Issue
Block a user