2017-03-28 22:25:44 +00:00
|
|
|
===============================================================================
|
|
|
|
ALE Rust Integration *ale-rust-options*
|
|
|
|
*ale-integration-rust*
|
|
|
|
|
2017-07-08 13:17:26 +00:00
|
|
|
===============================================================================
|
2017-03-28 22:25:44 +00:00
|
|
|
Integration Information
|
|
|
|
|
2018-08-01 16:47:10 +00:00
|
|
|
If Vim does not detect the Rust file type out-of-the-box, you need the runtime
|
|
|
|
files for Rust distributed in Vim >=8.0.0501 or upstream:
|
|
|
|
https://github.com/rust-lang/rust.vim
|
2017-03-28 22:25:44 +00:00
|
|
|
|
2019-12-11 17:01:28 +00:00
|
|
|
Note that there are several possible linters and fixers for Rust files:
|
2017-03-28 22:25:44 +00:00
|
|
|
|
|
|
|
1. rustc -- The Rust compiler is used to check the currently edited file.
|
|
|
|
So, if your project consists of multiple files, you will get some errors
|
|
|
|
when you use e.g. a struct which is defined in another file. You can use
|
|
|
|
|g:ale_rust_ignore_error_codes| to ignore some of these errors.
|
|
|
|
2. cargo -- If your project is managed by Cargo, the whole project is
|
|
|
|
checked. That means that all errors are properly shown, but cargo can
|
2017-03-28 23:34:03 +00:00
|
|
|
only operate on the files written on disk, so errors will not be reported
|
|
|
|
while you type.
|
2017-08-07 12:00:17 +00:00
|
|
|
3. rls -- If you have `rls` installed, you might prefer using this linter
|
|
|
|
over cargo. rls implements the Language Server Protocol for incremental
|
2017-10-02 16:11:54 +00:00
|
|
|
compilation of Rust code, and can check Rust files while you type. `rls`
|
2020-09-14 10:57:22 +00:00
|
|
|
requires Rust files to be contained in Cargo projects.
|
2019-12-11 17:01:28 +00:00
|
|
|
4. analyzer -- If you have rust-analyzer installed, you might prefer using
|
2019-10-16 15:34:06 +00:00
|
|
|
this linter over cargo and rls. rust-analyzer also implements the
|
|
|
|
Language Server Protocol for incremental compilation of Rust code, and is
|
2022-03-23 01:56:29 +00:00
|
|
|
the next iteration of rls. rust-analyzer either requires Rust files to be
|
|
|
|
contained in Cargo projects or requires the project to be described in
|
|
|
|
the rust-project.json format:
|
|
|
|
https://rust-analyzer.github.io/manual.html#non-cargo-based-projects
|
2019-12-11 17:01:28 +00:00
|
|
|
5. rustfmt -- If you have `rustfmt` installed, you can use it as a fixer to
|
2017-10-21 17:31:49 +00:00
|
|
|
consistently reformat your Rust code.
|
2017-03-28 22:25:44 +00:00
|
|
|
|
2020-08-28 07:23:02 +00:00
|
|
|
Only cargo and rls are enabled by default. To switch to using rustc instead
|
|
|
|
of cargo, configure |g:ale_linters| appropriately: >
|
2017-03-28 22:25:44 +00:00
|
|
|
|
|
|
|
" See the help text for the option for more information.
|
2020-08-28 07:23:02 +00:00
|
|
|
let g:ale_linters = {'rust': ['rustc', 'rls']}
|
2017-03-28 22:25:44 +00:00
|
|
|
<
|
|
|
|
|
2022-02-19 15:01:06 +00:00
|
|
|
Also note that rustc 1.18. or later is needed.
|
2017-03-28 22:25:44 +00:00
|
|
|
|
|
|
|
|
2019-10-16 18:41:04 +00:00
|
|
|
===============================================================================
|
|
|
|
analyzer *ale-rust-analyzer*
|
|
|
|
|
|
|
|
g:ale_rust_analyzer_executable *g:ale_rust_analyzer_executable*
|
|
|
|
*b:ale_rust_analyzer_executable*
|
|
|
|
Type: |String|
|
2020-04-09 17:23:03 +00:00
|
|
|
Default: `'rust-analyzer'`
|
2019-10-16 18:41:04 +00:00
|
|
|
|
|
|
|
This variable can be modified to change the executable path for
|
|
|
|
`rust-analyzer`.
|
|
|
|
|
|
|
|
|
|
|
|
g:ale_rust_analyzer_config *g:ale_rust_analyzer_config*
|
|
|
|
*b:ale_rust_analyzer_config*
|
|
|
|
Type: |Dictionary|
|
|
|
|
Default: `{}`
|
|
|
|
|
2023-07-24 00:35:54 +00:00
|
|
|
Dictionary with configuration settings for rust-analyzer. Keys of the
|
|
|
|
dictionary are components of configuration keys. For example:
|
|
|
|
>
|
|
|
|
let g:ale_rust_analyzer_config = {
|
|
|
|
\ 'server': {
|
|
|
|
\ 'extraEnv': { 'RUSTUP_TOOLCHAIN': 'stable' },
|
|
|
|
\ }
|
|
|
|
\}
|
|
|
|
<
|
|
|
|
corresponds to `rust-analyzer.server.extraEnv = { 'RUSTUP_TOOLCHAIN': 'stable' }`
|
|
|
|
|
|
|
|
For available configuration parameters, see the `rust-analyzer` manual:
|
2019-10-16 18:41:04 +00:00
|
|
|
|
2023-07-24 00:35:54 +00:00
|
|
|
https://rust-analyzer.github.io/manual.html#configuration
|
2020-08-28 07:23:02 +00:00
|
|
|
|
2017-07-08 13:17:26 +00:00
|
|
|
===============================================================================
|
2017-03-28 22:25:44 +00:00
|
|
|
cargo *ale-rust-cargo*
|
|
|
|
|
|
|
|
g:ale_rust_cargo_use_check *g:ale_rust_cargo_use_check*
|
2017-04-27 21:04:34 +00:00
|
|
|
*b:ale_rust_cargo_use_check*
|
2017-03-28 22:25:44 +00:00
|
|
|
Type: |Number|
|
2017-11-05 18:37:44 +00:00
|
|
|
Default: `1`
|
2017-03-28 22:25:44 +00:00
|
|
|
|
2017-11-05 18:37:44 +00:00
|
|
|
When set to `1`, this option will cause ALE to use `cargo check` instead of
|
|
|
|
`cargo build` . `cargo check` is supported since version 1.16.0 of Rust.
|
|
|
|
|
|
|
|
ALE will never use `cargo check` when the version of `cargo` is less than
|
|
|
|
0.17.0.
|
|
|
|
|
|
|
|
|
|
|
|
g:ale_rust_cargo_check_all_targets *g:ale_rust_cargo_check_all_targets*
|
|
|
|
*b:ale_rust_cargo_check_all_targets*
|
|
|
|
Type: |Number|
|
2017-12-07 18:47:01 +00:00
|
|
|
Default: `0`
|
2017-11-05 18:37:44 +00:00
|
|
|
|
|
|
|
When set to `1`, ALE will set the `--all-targets` option when `cargo check`
|
|
|
|
is used. See |g:ale_rust_cargo_use_check|,
|
2017-03-28 22:25:44 +00:00
|
|
|
|
|
|
|
|
2018-06-04 09:08:49 +00:00
|
|
|
g:ale_rust_cargo_check_tests *g:ale_rust_cargo_check_tests*
|
|
|
|
*b:ale_rust_cargo_check_tests*
|
|
|
|
Type: |Number|
|
|
|
|
Default: `0`
|
|
|
|
|
|
|
|
When set to `1`, ALE will set the `--tests` option when `cargo check`
|
|
|
|
is used. This allows for linting of tests which are normally excluded.
|
|
|
|
See |g:ale_rust_cargo_use_check|,
|
|
|
|
|
|
|
|
|
|
|
|
g:ale_rust_cargo_check_examples *g:ale_rust_cargo_check_examples*
|
|
|
|
*b:ale_rust_cargo_check_examples*
|
|
|
|
Type: |Number|
|
|
|
|
Default: `0`
|
|
|
|
|
|
|
|
When set to `1`, ALE will set the `--examples` option when `cargo check`
|
|
|
|
is used. This allows for linting of examples which are normally excluded.
|
|
|
|
See |g:ale_rust_cargo_use_check|,
|
|
|
|
|
|
|
|
|
2018-01-10 03:18:18 +00:00
|
|
|
g:ale_rust_cargo_default_feature_behavior
|
|
|
|
*g:ale_rust_cargo_default_feature_behavior*
|
|
|
|
*b:ale_rust_cargo_default_feature_behavior*
|
|
|
|
Type: |String|
|
|
|
|
Default: `default`
|
|
|
|
|
|
|
|
When set to `none`, ALE will set the `--no-default-features` option when
|
|
|
|
invoking `cargo`. Only the features specified in
|
|
|
|
|g:ale_rust_cargo_include_features| will be included when performing the
|
|
|
|
lint check.
|
|
|
|
|
|
|
|
When set to `default`, ALE will instruct `cargo` to build all default
|
|
|
|
features specified in the project's `Cargo.toml` file, in addition to
|
|
|
|
including any additional features defined in
|
|
|
|
|g:ale_rust_cargo_include_features|.
|
|
|
|
|
|
|
|
When set to `all`, ALE will set the `--all-features` option when
|
|
|
|
invoking `cargo`, which will include all features defined in the project's
|
|
|
|
`Cargo.toml` file when performing the lint check.
|
|
|
|
|
|
|
|
|
|
|
|
g:ale_rust_cargo_include_features *g:ale_rust_cargo_include_features*
|
|
|
|
*b:ale_rust_cargo_include_features*
|
|
|
|
Type: |String|
|
|
|
|
Default: `''`
|
|
|
|
|
|
|
|
When defined, ALE will set the `--features` option when invoking `cargo` to
|
|
|
|
perform the lint check. See |g:ale_rust_cargo_default_feature_behavior|.
|
|
|
|
|
2018-10-22 08:21:48 +00:00
|
|
|
|
2018-06-27 21:36:02 +00:00
|
|
|
g:ale_rust_cargo_avoid_whole_workspace *g:ale_rust_cargo_avoid_whole_workspace*
|
|
|
|
*b:ale_rust_cargo_avoid_whole_workspace*
|
|
|
|
Type: |Number|
|
|
|
|
Default: `1`
|
|
|
|
|
|
|
|
When set to 1, and ALE is used to edit a crate that is part of a Cargo
|
2018-09-09 21:33:53 +00:00
|
|
|
workspace, avoid building the entire workspace by invoking `cargo` directly
|
|
|
|
in the crate's directory. Otherwise, behave as usual.
|
2018-06-27 21:36:02 +00:00
|
|
|
|
2018-01-10 03:18:18 +00:00
|
|
|
|
2021-11-18 22:41:05 +00:00
|
|
|
g:ale_rust_cargo_use_clippy *g:ale_rust_cargo_use_clippy*
|
2018-10-22 08:21:48 +00:00
|
|
|
*b:ale_rust_cargo_use_clippy*
|
|
|
|
Type: |Number|
|
|
|
|
Default: `0`
|
|
|
|
|
|
|
|
When set to 1, `cargo clippy` will be used instead of `cargo check` or
|
|
|
|
`cargo build` as linter.
|
|
|
|
For details of `cargo clippy`, please visit the following link:
|
|
|
|
|
|
|
|
https://github.com/rust-lang-nursery/rust-clippy
|
|
|
|
|
|
|
|
Since `cargo clippy` is optional toolchain, it's safer to check whether
|
|
|
|
`cargo-clippy` is executable as follows:
|
|
|
|
>
|
|
|
|
let g:ale_rust_cargo_use_clippy = executable('cargo-clippy')
|
|
|
|
<
|
|
|
|
|
2021-11-18 22:41:05 +00:00
|
|
|
g:ale_rust_cargo_clippy_options *g:ale_rust_cargo_clippy_options*
|
2018-10-22 08:21:48 +00:00
|
|
|
*b:ale_rust_cargo_clippy_options*
|
|
|
|
|
|
|
|
Type: |String|
|
|
|
|
Default: `''`
|
|
|
|
|
|
|
|
When `cargo clippy` is used, this value will be added to a command line to run
|
|
|
|
it. This variable is useful when you want to add some extra options which
|
|
|
|
only `cargo clippy` supports (e.g. `--deny`).
|
|
|
|
|
|
|
|
|
2021-11-18 22:41:05 +00:00
|
|
|
g:ale_rust_cargo_target_dir *g:ale_rust_cargo_target_dir*
|
2020-05-10 12:21:02 +00:00
|
|
|
*b:ale_rust_cargo_target_dir*
|
|
|
|
|
|
|
|
Type: |String|
|
|
|
|
Default: `''`
|
|
|
|
|
|
|
|
Use a custom target directory when running the commands for ALE. This can
|
|
|
|
help to avoid "waiting for file lock on build directory" messages when
|
|
|
|
running `cargo` commands manually while ALE is performing its checks.
|
|
|
|
|
|
|
|
|
2021-11-18 22:41:05 +00:00
|
|
|
===============================================================================
|
|
|
|
cspell *ale-rust-cspell*
|
|
|
|
|
|
|
|
See |ale-cspell-options|
|
|
|
|
|
|
|
|
|
2017-08-07 12:00:17 +00:00
|
|
|
===============================================================================
|
|
|
|
rls *ale-rust-rls*
|
|
|
|
|
|
|
|
g:ale_rust_rls_executable *g:ale_rust_rls_executable*
|
|
|
|
*b:ale_rust_rls_executable*
|
|
|
|
Type: |String|
|
|
|
|
Default: `'rls'`
|
|
|
|
|
|
|
|
This variable can be modified to change the executable path for `rls`.
|
|
|
|
|
|
|
|
|
2017-11-26 18:47:30 +00:00
|
|
|
g:ale_rust_rls_toolchain *g:ale_rust_rls_toolchain*
|
|
|
|
*b:ale_rust_rls_toolchain*
|
|
|
|
Type: |String|
|
2019-04-11 13:25:08 +00:00
|
|
|
Default: `''`
|
2017-11-26 18:47:30 +00:00
|
|
|
|
|
|
|
This option can be set to change the toolchain used for `rls`. Possible
|
2019-04-11 13:25:08 +00:00
|
|
|
values include `'nightly'`, `'beta'`, `'stable'`, and `''`. When using
|
|
|
|
option `''`, rls will automatically find the default toolchain set by
|
|
|
|
rustup. If you want to use `rls` from a specific toolchain version, you may
|
|
|
|
also use values like `'channel-yyyy-mm-dd-arch-target'` as long as
|
|
|
|
`'rls +{toolchain_name} -V'` runs correctly in your command line.
|
2017-11-26 18:47:30 +00:00
|
|
|
|
|
|
|
The `rls` server will only be started once per executable.
|
|
|
|
|
|
|
|
|
2019-03-05 09:09:29 +00:00
|
|
|
g:ale_rust_rls_config *g:ale_rust_rls_config*
|
|
|
|
*b:ale_rust_rls_config*
|
|
|
|
Type: |Dictionary|
|
|
|
|
Default: `{}`
|
|
|
|
|
|
|
|
Dictionary with configuration settings for rls. For example, to force
|
|
|
|
using clippy as linter: >
|
|
|
|
{
|
|
|
|
\ 'rust': {
|
|
|
|
\ 'clippy_preference': 'on'
|
|
|
|
\ }
|
|
|
|
\ }
|
|
|
|
|
|
|
|
|
2017-07-08 13:17:26 +00:00
|
|
|
===============================================================================
|
2017-03-28 22:25:44 +00:00
|
|
|
rustc *ale-rust-rustc*
|
|
|
|
|
2017-12-19 18:10:29 +00:00
|
|
|
|
|
|
|
g:ale_rust_rustc_options *g:ale_rust_rustc_options*
|
|
|
|
*b:ale_rust_rustc_options*
|
|
|
|
Type: |String|
|
2022-02-19 15:01:06 +00:00
|
|
|
Default: `'--emit=mir -o /dev/null'`
|
2017-12-19 18:10:29 +00:00
|
|
|
|
|
|
|
The variable can be used to change the options passed to `rustc`.
|
|
|
|
|
2022-02-19 15:01:06 +00:00
|
|
|
Users of nightly builds of Rust might want to use `-Z no-codegen` instead.
|
|
|
|
Be careful when setting the options, as running `rustc` could execute code
|
|
|
|
or generate binary files.
|
2017-12-19 18:10:29 +00:00
|
|
|
|
|
|
|
|
2017-03-28 22:25:44 +00:00
|
|
|
g:ale_rust_ignore_error_codes *g:ale_rust_ignore_error_codes*
|
2017-04-27 21:04:34 +00:00
|
|
|
*b:ale_rust_ignore_error_codes*
|
2017-03-28 22:25:44 +00:00
|
|
|
Type: |List| of |String|s
|
2017-08-07 12:00:17 +00:00
|
|
|
Default: `[]`
|
2017-03-28 22:25:44 +00:00
|
|
|
|
|
|
|
This variable can contain error codes which will be ignored. For example, to
|
|
|
|
ignore most errors regarding failed imports, put this in your .vimrc
|
|
|
|
>
|
|
|
|
let g:ale_rust_ignore_error_codes = ['E0432', 'E0433']
|
|
|
|
|
2020-08-28 07:23:02 +00:00
|
|
|
|
2018-10-26 08:38:20 +00:00
|
|
|
g:ale_rust_ignore_secondary_spans *g:ale_rust_ignore_secondary_spans*
|
|
|
|
*b:ale_rust_ignore_secondary_spans*
|
2022-10-29 11:56:47 +00:00
|
|
|
Type: |Number|
|
|
|
|
Default: `0`
|
2018-10-26 08:38:20 +00:00
|
|
|
|
2020-08-28 07:23:02 +00:00
|
|
|
When set to 1, instructs the Rust error reporting to ignore secondary spans.
|
|
|
|
The problem with secondary spans is that they sometimes appear in error
|
|
|
|
messages before the main cause of the error, for example: >
|
2018-10-26 08:38:20 +00:00
|
|
|
|
|
|
|
1 src/main.rs|98 col 5 error| this function takes 4 parameters but 5
|
2020-08-28 07:23:02 +00:00
|
|
|
parameters were supplied: defined here
|
2018-10-26 08:38:20 +00:00
|
|
|
2 src/main.rs|430 col 32 error| this function takes 4 parameters but 5
|
2020-08-28 07:23:02 +00:00
|
|
|
parameters were supplied: expected 4 parameters
|
2018-10-26 08:38:20 +00:00
|
|
|
<
|
|
|
|
This is due to the sorting by line numbers. With this option set to 1,
|
|
|
|
the 'defined here' span will not be presented.
|
2017-03-28 22:25:44 +00:00
|
|
|
|
2020-08-28 07:23:02 +00:00
|
|
|
|
2017-10-21 17:31:49 +00:00
|
|
|
===============================================================================
|
|
|
|
rustfmt *ale-rust-rustfmt*
|
|
|
|
|
|
|
|
g:ale_rust_rustfmt_options *g:ale_rust_rustfmt_options*
|
|
|
|
*b:ale_rust_rustfmt_options*
|
|
|
|
Type: |String|
|
|
|
|
Default: `''`
|
|
|
|
|
|
|
|
This variable can be set to pass additional options to the rustfmt fixer.
|
|
|
|
|
|
|
|
|
2022-11-22 01:28:39 +00:00
|
|
|
g:ale_rust_rustfmt_executable *g:ale_rust_rustfmt_executable*
|
|
|
|
*b:ale_rust_rustfmt_executable*
|
|
|
|
Type: |String|
|
|
|
|
Default: `'rustfmt'`
|
|
|
|
|
|
|
|
This variable can be modified to change the executable path for `rustfmt`.
|
|
|
|
|
|
|
|
|
2017-07-08 13:17:26 +00:00
|
|
|
===============================================================================
|
2017-03-28 22:25:44 +00:00
|
|
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|