Skip to content

Commit ad536ae

Browse files
committed
Syntastic: allow to control what parts of the crate are checked
This allows to control the arguments to Cargo which determine what targets in the crate will be checked. This is similar what is done in the ALE Rust checker.
1 parent 21a870b commit ad536ae

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

doc/rust.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ SETTINGS *rust-settings*
2020
This plugin has a few variables you can define in your vimrc that change the
2121
behavior of the plugin.
2222

23+
Some variables can be set buffer local (`:b` prefix), and the buffer local
24+
will take precedence over the global `g:` counterpart.
25+
2326
*g:rustc_path*
2427
g:rustc_path~
2528
Set this option to the path to rustc for use in the |:RustRun| and
@@ -199,6 +202,38 @@ g:rust_cargo_avoid_whole_workspace~
199202
workspace. >
200203
let g:rust_cargo_avoid_whole_workspace = 0
201204
<
205+
*g:rust_cargo_check_all_targets*
206+
*b:rust_cargo_check_all_targets*
207+
g:rust_cargo_check_all_targets~
208+
When set to 1, the `--all-targets` option will be passed to cargo when
209+
Syntastic executes it, allowing the linting of all targets under the
210+
package.
211+
The default is 0.
212+
213+
*g:rust_cargo_check_examples*
214+
*b:rust_cargo_check_examples*
215+
g:rust_cargo_check_examples~
216+
When set to 1, the `--examples` option will be passed to cargo when
217+
Syntastic executes it, to prevent the exclusion of examples from
218+
linting. The examples are normally under the `examples/` directory of
219+
the crate.
220+
The default is 0.
221+
222+
*g:rust_cargo_check_tests*
223+
*b:rust_cargo_check_tests*
224+
g:rust_cargo_check_tests~
225+
When set to 1, the `--tests` option will be passed to cargo when
226+
Syntastic executes it, to prevent the exclusion of tests from linting.
227+
The tests are normally under the `tests/` directory of the crate.
228+
The default is 0.
229+
230+
*g:rust_cargo_check_benches*
231+
*b:rust_cargo_check_benches*
232+
g:rust_cargo_check_benches~
233+
When set to 1, the `--benches` option will be passed to cargo when
234+
Syntastic executes it. The benches are normally under the `benches/`
235+
directory of the crate.
236+
The default is 0.
202237

203238
==============================================================================
204239
COMMANDS *rust-commands*

syntax_checkers/rust/cargo.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ function! SyntaxCheckers_rust_cargo_GetLocList() dict
4545
\ . " && " . makeprg
4646
endif
4747

48+
let l:check_all_targets = rust#GetConfigVar('rust_cargo_check_all_targets', 0)
49+
let l:check_examples = rust#GetConfigVar('rust_cargo_check_examples', 0)
50+
let l:check_tests = rust#GetConfigVar('rust_cargo_check_tests', 0)
51+
let l:check_benches = rust#GetConfigVar('rust_cargo_check_benches', 0)
52+
53+
let makeprg = makeprg. ' '
54+
\ . (l:check_all_targets ? ' --all-targets' : '')
55+
\ . (l:check_benches ? ' --benches' : '')
56+
\ . (l:check_examples ? ' --examples' : '')
57+
\ . (l:check_tests ? ' --tests' : '')
58+
4859
" Ignored patterns, and blank lines
4960
let errorformat =
5061
\ '%-G,' .

0 commit comments

Comments
 (0)