summaryrefslogtreecommitdiff
path: root/ale_linters/rust/cargo.vim
diff options
context:
space:
mode:
authorEinfachToll <istjanichtzufassen@googlemail.com>2017-01-12 10:33:55 +0100
committerw0rp <w0rp@users.noreply.github.com>2017-01-12 09:33:55 +0000
commit9c5f092b4f9464d035d6a334b3053f2f3eb95c22 (patch)
tree581ae70db5f0ebcf23a80bdae49585d122a9f763 /ale_linters/rust/cargo.vim
parent75485d53f67ab665fb7a4e13803d87c71b7368ae (diff)
downloadale-9c5f092b4f9464d035d6a334b3053f2f3eb95c22.zip
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
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..0cfc1665
--- /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#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',
+\})