summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/rust/cargo.vim10
-rw-r--r--test/command_callback/test_cargo_command_callbacks.vader10
2 files changed, 18 insertions, 2 deletions
diff --git a/ale_linters/rust/cargo.vim b/ale_linters/rust/cargo.vim
index f98dee9b..8ea6f19c 100644
--- a/ale_linters/rust/cargo.vim
+++ b/ale_linters/rust/cargo.vim
@@ -69,7 +69,15 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort
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')
+
+ let l:clippy_options = ale#Var(a:buffer, 'rust_cargo_clippy_options')
+ if l:clippy_options =~ "^-- "
+ let l:clippy_options = join(split(l:clippy_options, '-- '))
+ endif
+
+ if l:clippy_options isnot# ''
+ let l:clippy_options = ' -- ' . l:clippy_options
+ endif
endif
return l:nearest_cargo_prefix . 'cargo '
diff --git a/test/command_callback/test_cargo_command_callbacks.vader b/test/command_callback/test_cargo_command_callbacks.vader
index 438c97db..42ca0301 100644
--- a/test/command_callback/test_cargo_command_callbacks.vader
+++ b/test/command_callback/test_cargo_command_callbacks.vader
@@ -141,7 +141,7 @@ Execute(When ale_rust_cargo_use_clippy is set, cargo-clippy is used as linter):
let b:ale_rust_cargo_use_clippy = 1
AssertLinter 'cargo', [
\ ale#Escape('cargo') . ' --version',
- \ 'cargo clippy --frozen --message-format=json -q ',
+ \ 'cargo clippy --frozen --message-format=json -q',
\]
Execute(When ale_rust_cargo_clippy_options is set, cargo-clippy appends it to commandline):
@@ -152,6 +152,14 @@ Execute(When ale_rust_cargo_clippy_options is set, cargo-clippy appends it to co
\ 'cargo clippy --frozen --message-format=json -q -- -D warnings',
\]
+Execute(When ale_rust_cargo_clippy_options does not start with --, it is added):
+ let b:ale_rust_cargo_use_clippy = 1
+ let b:ale_rust_cargo_clippy_options = '-D warnings'
+ AssertLinter 'cargo', [
+ \ ale#Escape('cargo') . ' --version',
+ \ 'cargo clippy --frozen --message-format=json -q -- -D warnings',
+ \]
+
Execute(cargo-check does not refer ale_rust_cargo_clippy_options):
let b:ale_rust_cargo_use_clippy = 0
let b:ale_rust_cargo_use_check = 1