From f57ad883f2ddb0613ffeffa4529269a6bcaf913a Mon Sep 17 00:00:00 2001 From: Linda_pp Date: Mon, 22 Oct 2018 17:21:48 +0900 Subject: Add support for `cargo clippy` (#2001) * Add support for `cargo clippy` * Add tests for cargo-clippy support * Add an example to doc for how to configure ale_rust_cargo_use_clippy --- ale_linters/rust/cargo.vim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'ale_linters/rust/cargo.vim') diff --git a/ale_linters/rust/cargo.vim b/ale_linters/rust/cargo.vim index 5aefe72c..cf6187f8 100644 --- a/ale_linters/rust/cargo.vim +++ b/ale_linters/rust/cargo.vim @@ -9,6 +9,8 @@ call ale#Set('rust_cargo_check_tests', 0) call ale#Set('rust_cargo_avoid_whole_workspace', 1) call ale#Set('rust_cargo_default_feature_behavior', 'default') call ale#Set('rust_cargo_include_features', '') +call ale#Set('rust_cargo_use_clippy', 0) +call ale#Set('rust_cargo_clippy_options', '') function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort if ale#path#FindNearestFile(a:bufnr, 'Cargo.toml') isnot# '' @@ -70,14 +72,23 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version_output) abort let l:default_feature = '' endif + let l:subcommand = l:use_check ? 'check' : 'build' + let l:clippy_options = '' + + if ale#Var(a:buffer, 'rust_cargo_use_clippy') + let l:subcommand = 'clippy' + let l:clippy_options = ' ' . ale#Var(a:buffer, 'rust_cargo_clippy_options') + endif + return l:nearest_cargo_prefix . 'cargo ' - \ . (l:use_check ? 'check' : 'build') + \ . l:subcommand \ . (l:use_all_targets ? ' --all-targets' : '') \ . (l:use_examples ? ' --examples' : '') \ . (l:use_tests ? ' --tests' : '') \ . ' --frozen --message-format=json -q' \ . l:default_feature \ . l:include_features + \ . l:clippy_options endfunction call ale#linter#Define('rust', { -- cgit v1.2.3