1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-04 05:40:06 +08:00
SpaceVim/bundle/ale/ale_linters/go/staticcheck.vim

35 lines
1.1 KiB
VimL
Raw Normal View History

2021-02-10 10:31:34 +08:00
" Author: Ben Reedy <https://github.com/breed808>
" Description: staticcheck for Go files
2023-06-09 12:10:45 +08:00
call ale#Set('go_staticcheck_executable', 'staticcheck')
2021-02-10 10:31:34 +08:00
call ale#Set('go_staticcheck_options', '')
2023-06-09 12:10:45 +08:00
call ale#Set('go_staticcheck_lint_package', 1)
call ale#Set('go_staticcheck_use_global', get(g:, 'ale_use_global_executables', 0))
2021-02-10 10:31:34 +08: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')
let l:env = ale#go#EnvString(a:buffer)
if l:lint_package
2023-06-09 12:10:45 +08:00
return l:env . '%e'
2021-02-10 10:31:34 +08:00
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endif
2023-06-09 12:10:45 +08:00
return l:env . '%e'
2021-02-10 10:31:34 +08:00
\ . (!empty(l:options) ? ' ' . l:options : '')
2023-06-09 12:10:45 +08:00
\ . ' %s:t'
2021-02-10 10:31:34 +08:00
endfunction
call ale#linter#Define('go', {
\ 'name': 'staticcheck',
2023-06-09 12:10:45 +08:00
\ 'executable': {b -> ale#path#FindExecutable(b, 'go_staticcheck', [
\ ale#go#GetGoPathExecutable('bin/staticcheck'),
\ ])},
\ 'cwd': '%s:h',
2021-02-10 10:31:34 +08:00
\ 'command': function('ale_linters#go#staticcheck#GetCommand'),
\ 'callback': 'ale#handlers#go#Handler',
\ 'output_stream': 'both',
\ 'lint_file': 1,
\})