2017-01-12 09:33:55 +00:00
|
|
|
" Author: Daniel Schemala <istjanichtzufassen@gmail.com>
|
|
|
|
" Description: rustc for rust files
|
|
|
|
|
2017-01-13 09:23:03 +00:00
|
|
|
function! ale_linters#rust#rustc#RustcCommand(buffer_number) abort
|
2017-01-12 09:33:55 +00:00
|
|
|
" Try to guess the library search path. If the project is managed by cargo,
|
|
|
|
" it's usually <project root>/target/debug/deps/ or
|
|
|
|
" <project root>/target/release/deps/
|
|
|
|
let l:cargo_file = ale#util#FindNearestFile(a:buffer_number, 'Cargo.toml')
|
|
|
|
|
|
|
|
if l:cargo_file !=# ''
|
|
|
|
let l:project_root = fnamemodify(l:cargo_file, ':h')
|
|
|
|
let l:dependencies = '-L ' . l:project_root . '/target/debug/deps -L ' .
|
|
|
|
\ l:project_root . '/target/release/deps'
|
|
|
|
else
|
|
|
|
let l:dependencies = ''
|
|
|
|
endif
|
|
|
|
|
|
|
|
return 'rustc --error-format=json -Z no-trans ' . l:dependencies . ' -'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('rust', {
|
|
|
|
\ 'name': 'rustc',
|
|
|
|
\ 'executable': 'rustc',
|
2017-01-13 09:23:03 +00:00
|
|
|
\ 'command_callback': 'ale_linters#rust#rustc#RustcCommand',
|
2017-02-07 21:17:03 +00:00
|
|
|
\ 'callback': 'ale#handlers#rust#HandleRustErrors',
|
2017-01-12 09:33:55 +00:00
|
|
|
\ 'output_stream': 'stderr',
|
|
|
|
\})
|