mirror of
https://github.com/dense-analysis/ale
synced 2024-12-22 06:10:07 +00:00
49db8210f6
Allows the user to override $GO111MODULE environment variable through ale options. This gives control over the default behavior of Go module resolution. Golang documentation: https://github.com/golang/go/wiki/Modules#how-to-use-modules Add `ale#Go#EnvString()` function to make it easy to add similar Go environment variables in the future. Use the new `EnvString` function in all available Go tools callbacks & update tests Also add test of linter command callback for `gofmt`
32 lines
1.1 KiB
VimL
32 lines
1.1 KiB
VimL
" Author: Jerko Steiner <https://github.com/jeremija>
|
|
" Description: https://github.com/saibing/bingo
|
|
|
|
call ale#Set('go_bingo_executable', 'bingo')
|
|
call ale#Set('go_bingo_options', '--mode stdio')
|
|
|
|
function! ale_linters#go#bingo#GetCommand(buffer) abort
|
|
return ale#go#EnvString(a:buffer) . '%e' . ale#Pad(ale#Var(a:buffer, 'go_bingo_options'))
|
|
endfunction
|
|
|
|
function! ale_linters#go#bingo#FindProjectRoot(buffer) abort
|
|
let l:go_modules_off = ale#Var(a:buffer, 'go_go111module') is# 'off'
|
|
let l:project_root = l:go_modules_off ?
|
|
\ '' : ale#path#FindNearestFile(a:buffer, 'go.mod')
|
|
let l:mods = ':h'
|
|
|
|
if empty(l:project_root)
|
|
let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git')
|
|
let l:mods = ':h:h'
|
|
endif
|
|
|
|
return !empty(l:project_root) ? fnamemodify(l:project_root, l:mods) : ''
|
|
endfunction
|
|
|
|
call ale#linter#Define('go', {
|
|
\ 'name': 'bingo',
|
|
\ 'lsp': 'stdio',
|
|
\ 'executable': {b -> ale#Var(b, 'go_bingo_executable')},
|
|
\ 'command': function('ale_linters#go#bingo#GetCommand'),
|
|
\ 'project_root': function('ale_linters#go#bingo#FindProjectRoot'),
|
|
\})
|