2017-01-12 04:33:55 -05:00
|
|
|
" Author: Daniel Schemala <istjanichtzufassen@gmail.com>
|
|
|
|
" Description: rustc invoked by cargo for rust files
|
|
|
|
|
|
|
|
|
2017-01-22 09:54:57 -05:00
|
|
|
function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort
|
2017-01-12 04:33:55 -05:00
|
|
|
if ale#util#FindNearestFile(a:bufnr, 'Cargo.toml') !=# ''
|
|
|
|
return 'cargo'
|
|
|
|
else
|
|
|
|
" if there is no Cargo.toml file, we don't use cargo even if it exists,
|
|
|
|
" so we return '', because executable('') apparently always fails
|
|
|
|
return ''
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('rust', {
|
|
|
|
\ 'name': 'cargo',
|
2017-01-13 04:23:03 -05:00
|
|
|
\ 'executable_callback': 'ale_linters#rust#cargo#GetCargoExecutable',
|
2017-01-12 04:33:55 -05:00
|
|
|
\ 'command': 'cargo rustc -- --error-format=json -Z no-trans',
|
2017-01-13 04:23:03 -05:00
|
|
|
\ 'callback': 'ale_linters#rust#rustc#HandleRustcErrors',
|
2017-01-12 04:33:55 -05:00
|
|
|
\ 'output_stream': 'stderr',
|
|
|
|
\})
|