mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Add support for Rust using rustc and cargo (#230)
* Add rustc checker for rust files * Add documentation for rustc * Use a nice helper function * Add cargo as linter * Complete the doc for rust linters * Put l: in front of every local variable * Apply the requested stylistic changes
This commit is contained in:
21
ale_linters/rust/cargo.vim
Normal file
21
ale_linters/rust/cargo.vim
Normal file
@@ -0,0 +1,21 @@
|
||||
" Author: Daniel Schemala <istjanichtzufassen@gmail.com>
|
||||
" Description: rustc invoked by cargo for rust files
|
||||
|
||||
|
||||
function! ale_linters#rust#cargo#cargo_or_not_cargo(bufnr)
|
||||
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',
|
||||
\ 'executable_callback': 'ale_linters#rust#cargo#cargo_or_not_cargo',
|
||||
\ 'command': 'cargo rustc -- --error-format=json -Z no-trans',
|
||||
\ 'callback': 'ale_linters#rust#rustc#handle_rustc_errors',
|
||||
\ 'output_stream': 'stderr',
|
||||
\})
|
||||
Reference in New Issue
Block a user