2017-03-30 01:42:16 +00:00
|
|
|
" Author: Ben Reedy <https://github.com/breed808>
|
|
|
|
" Description: staticcheck for Go files
|
|
|
|
|
2021-05-27 21:03:39 +00:00
|
|
|
call ale#Set('go_staticcheck_executable', 'staticcheck')
|
2018-02-15 11:23:36 +00:00
|
|
|
call ale#Set('go_staticcheck_options', '')
|
2021-07-03 09:40:01 +00:00
|
|
|
call ale#Set('go_staticcheck_lint_package', 1)
|
2021-05-27 21:03:39 +00:00
|
|
|
call ale#Set('go_staticcheck_use_global', get(g:, 'ale_use_global_executables', 0))
|
2018-02-15 11:23:36 +00:00
|
|
|
|
|
|
|
function! ale_linters#go#staticcheck#GetCommand(buffer) abort
|
|
|
|
let l:options = ale#Var(a:buffer, 'go_staticcheck_options')
|
|
|
|
let l:lint_package = ale#Var(a:buffer, 'go_staticcheck_lint_package')
|
2019-04-11 02:25:06 +00:00
|
|
|
let l:env = ale#go#EnvString(a:buffer)
|
2018-02-15 11:23:36 +00:00
|
|
|
|
|
|
|
if l:lint_package
|
2021-05-27 21:03:39 +00:00
|
|
|
return l:env . '%e'
|
2018-02-15 11:23:36 +00:00
|
|
|
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
|
|
|
|
endif
|
|
|
|
|
2021-05-27 21:03:39 +00:00
|
|
|
return l:env . '%e'
|
2018-02-15 11:23:36 +00:00
|
|
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
2021-03-01 20:11:10 +00:00
|
|
|
\ . ' %s:t'
|
2018-02-15 11:23:36 +00:00
|
|
|
endfunction
|
|
|
|
|
2017-03-30 01:42:16 +00:00
|
|
|
call ale#linter#Define('go', {
|
|
|
|
\ 'name': 'staticcheck',
|
2021-05-27 21:03:39 +00:00
|
|
|
\ 'executable': {b -> ale#path#FindExecutable(b, 'go_staticcheck', [
|
|
|
|
\ ale#go#GetGoPathExecutable('bin/staticcheck'),
|
|
|
|
\ ])},
|
2021-03-01 20:11:10 +00:00
|
|
|
\ 'cwd': '%s:h',
|
2019-02-22 18:05:04 +00:00
|
|
|
\ 'command': function('ale_linters#go#staticcheck#GetCommand'),
|
2018-03-20 14:19:48 +00:00
|
|
|
\ 'callback': 'ale#handlers#go#Handler',
|
2017-10-31 13:00:55 +00:00
|
|
|
\ 'output_stream': 'both',
|
|
|
|
\ 'lint_file': 1,
|
2017-03-30 01:42:16 +00:00
|
|
|
\})
|