2017-03-29 21:42:16 -04:00
|
|
|
" Author: Ben Reedy <https://github.com/breed808>
|
|
|
|
" Description: staticcheck for Go files
|
|
|
|
|
2018-02-15 06:23:36 -05:00
|
|
|
call ale#Set('go_staticcheck_options', '')
|
|
|
|
call ale#Set('go_staticcheck_lint_package', 0)
|
|
|
|
|
|
|
|
function! ale_linters#go#staticcheck#GetCommand(buffer) abort
|
|
|
|
let l:filename = expand('#' . a:buffer . ':t')
|
|
|
|
let l:options = ale#Var(a:buffer, 'go_staticcheck_options')
|
|
|
|
let l:lint_package = ale#Var(a:buffer, 'go_staticcheck_lint_package')
|
|
|
|
|
|
|
|
" BufferCdString is used so that we can be sure the paths output from
|
|
|
|
" staticcheck can be calculated to absolute paths in the Handler
|
|
|
|
if l:lint_package
|
|
|
|
return ale#path#BufferCdString(a:buffer)
|
|
|
|
\ . 'staticcheck'
|
|
|
|
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
|
|
|
|
endif
|
|
|
|
|
|
|
|
return ale#path#BufferCdString(a:buffer)
|
|
|
|
\ . 'staticcheck'
|
|
|
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
|
|
|
\ . ' ' . ale#Escape(l:filename)
|
|
|
|
endfunction
|
|
|
|
|
2017-03-29 21:42:16 -04:00
|
|
|
call ale#linter#Define('go', {
|
|
|
|
\ 'name': 'staticcheck',
|
|
|
|
\ 'executable': 'staticcheck',
|
2018-02-15 06:23:36 -05:00
|
|
|
\ 'command_callback': 'ale_linters#go#staticcheck#GetCommand',
|
2017-04-24 17:27:18 -04:00
|
|
|
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
2017-10-31 09:00:55 -04:00
|
|
|
\ 'output_stream': 'both',
|
|
|
|
\ 'lint_file': 1,
|
2017-03-29 21:42:16 -04:00
|
|
|
\})
|