summaryrefslogtreecommitdiff
path: root/ale_linters/rust
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters/rust')
-rw-r--r--ale_linters/rust/cargo.vim15
-rw-r--r--ale_linters/rust/rls.vim13
-rw-r--r--ale_linters/rust/rustc.vim2
3 files changed, 17 insertions, 13 deletions
diff --git a/ale_linters/rust/cargo.vim b/ale_linters/rust/cargo.vim
index e6c3870a..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# ''
@@ -42,6 +44,7 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version_output) abort
\ && ale#semver#GTE(l:version, [0, 22, 0])
let l:include_features = ale#Var(a:buffer, 'rust_cargo_include_features')
+
if !empty(l:include_features)
let l:include_features = ' --features ' . ale#Escape(l:include_features)
endif
@@ -59,6 +62,7 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version_output) abort
endif
let l:default_feature_behavior = ale#Var(a:buffer, 'rust_cargo_default_feature_behavior')
+
if l:default_feature_behavior is# 'all'
let l:include_features = ''
let l:default_feature = ' --all-features'
@@ -68,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', {
diff --git a/ale_linters/rust/rls.vim b/ale_linters/rust/rls.vim
index cd13291d..60dd3667 100644
--- a/ale_linters/rust/rls.vim
+++ b/ale_linters/rust/rls.vim
@@ -4,19 +4,10 @@
call ale#Set('rust_rls_executable', 'rls')
call ale#Set('rust_rls_toolchain', 'nightly')
-function! ale_linters#rust#rls#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'rust_rls_executable')
-endfunction
-
function! ale_linters#rust#rls#GetCommand(buffer) abort
- let l:executable = ale_linters#rust#rls#GetExecutable(a:buffer)
let l:toolchain = ale#Var(a:buffer, 'rust_rls_toolchain')
- if empty(l:toolchain)
- return ale#Escape(l:executable)
- else
- return ale#Escape(l:executable) . ' +' . ale#Escape(l:toolchain)
- endif
+ return '%e' . (!empty(l:toolchain) ? ' +' . ale#Escape(l:toolchain) : '')
endfunction
function! ale_linters#rust#rls#GetProjectRoot(buffer) abort
@@ -28,7 +19,7 @@ endfunction
call ale#linter#Define('rust', {
\ 'name': 'rls',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#rust#rls#GetExecutable',
+\ 'executable_callback': ale#VarFunc('rust_rls_executable'),
\ 'command_callback': 'ale_linters#rust#rls#GetCommand',
\ 'project_root_callback': 'ale_linters#rust#rls#GetProjectRoot',
\})
diff --git a/ale_linters/rust/rustc.vim b/ale_linters/rust/rustc.vim
index 3cd401b3..33fb72f4 100644
--- a/ale_linters/rust/rustc.vim
+++ b/ale_linters/rust/rustc.vim
@@ -1,7 +1,7 @@
" Author: Daniel Schemala <istjanichtzufassen@gmail.com>
" Description: rustc for rust files
-call ale#Set('rust_rustc_options', '-Z no-trans')
+call ale#Set('rust_rustc_options', '-Z no-codegen')
function! ale_linters#rust#rustc#RustcCommand(buffer) abort
" Try to guess the library search path. If the project is managed by cargo,