summaryrefslogtreecommitdiff
path: root/ale_linters/rust/cargo.vim
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters/rust/cargo.vim')
-rw-r--r--ale_linters/rust/cargo.vim21
1 files changed, 21 insertions, 0 deletions
diff --git a/ale_linters/rust/cargo.vim b/ale_linters/rust/cargo.vim
new file mode 100644
index 00000000..0f04f275
--- /dev/null
+++ b/ale_linters/rust/cargo.vim
@@ -0,0 +1,21 @@
+" Author: Daniel Schemala <istjanichtzufassen@gmail.com>
+" Description: rustc invoked by cargo for rust files
+
+
+function! ale_linters#rust#cargo#GetCargoExecutable(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#GetCargoExecutable',
+\ 'command': 'cargo rustc -- --error-format=json -Z no-trans',
+\ 'callback': 'ale_linters#rust#rustc#HandleRustcErrors',
+\ 'output_stream': 'stderr',
+\})