2019-01-05 19:12:55 +00:00
|
|
|
" 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
|
2019-04-11 02:25:06 +00:00
|
|
|
return ale#go#EnvString(a:buffer) . '%e' . ale#Pad(ale#Var(a:buffer, 'go_bingo_options'))
|
2019-01-05 19:12:55 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#go#bingo#FindProjectRoot(buffer) abort
|
2019-04-11 02:25:06 +00:00
|
|
|
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')
|
2019-01-05 19:12:55 +00:00
|
|
|
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',
|
2019-02-22 18:05:04 +00:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'go_bingo_executable')},
|
|
|
|
\ 'command': function('ale_linters#go#bingo#GetCommand'),
|
|
|
|
\ 'project_root': function('ale_linters#go#bingo#FindProjectRoot'),
|
2019-01-05 19:12:55 +00:00
|
|
|
\})
|