2022-06-27
Rust Analyzer Options
type: ['null', 'string']
Custom
cargo runner extension ID.
anyOf:
{'type': 'null'}
{'type': 'array', 'items': {'type': 'object', 'properties': {'mask': {'type': 'string', 'description': 'Runnable name mask'}, 'env': {'type': 'object', 'description': 'Variables in form of { "key": "value"}'}}}}
{'type': 'object', 'description': 'Variables in form of { "key": "value"}'}
Environment variables passed to the runnable launched using
Test
or Debug
lens or
rust-analyzer.run
command.
type: ['null', 'string']
Path to
rust-analyzer executable (points to bundled binary by default).
key | value |
---|---|
scope | machine-overridable |
type: ['null', 'object']
Extra
environment variables that will be passed to the rust-analyzer
executable. Useful for passing e.g. RA_LOG
for
debugging.
key | value |
---|---|
additionalProperties | {‘type’: [‘string’, ‘number’]} |
type: string
default: off
Trace requests to the
rust-analyzer (this is usually overly verbose and not recommended for
regular users).
value | description |
---|---|
off | No traces |
messages | Error only |
verbose | Full log |
key | value |
---|---|
scope | window |
type: boolean
default: False
Enable logging of VS
Code extensions itself.
type: string
default: auto
Preferred debug
engine.
value | description |
---|---|
auto | First try to use CodeLLDB, if it’s not installed try to use MS C++ tools. |
vadimcn.vscode-lldb | Use CodeLLDB |
ms-vscode.cpptools | Use MS C++ tools |
type: ['object', 'string']
default:
{
"/rustc/<id>": "${env:USERPROFILE}/.rustup/toolchains/<toolchain-id>/lib/rustlib/src/rust"
}
Optional source file mappings passed to the debug engine.
key | value |
---|---|
const | auto |
type: boolean
default: False
Whether to open up the
Debug Panel
on debugging start.
type: object
default: {}
Optional settings passed
to the debug engine. Example:
{ "lldb": { "terminal":"external"} }
type: string
default: todo
Placeholder expression
to use for missing expressions in assists.
value | description |
---|---|
todo | Fill missing expressions with the
todo macro |
default | Fill missing expressions with reasonable
defaults, new or default constructors. |
type: boolean
default: True
Warm up caches on
project load.
type: number
default: 0
minimum:
0
maximum: 255
How
many worker threads to handle priming caches. The default 0
means to pick automatically.
type: boolean
default: True
Automatically refresh
project info via cargo metadata
on Cargo.toml
or .cargo/config.toml
changes.
type: boolean
default: True
Run build scripts
(build.rs
) for more precise code analysis.
type: ['null', 'array']
Override
the command rust-analyzer uses to run build scripts and build procedural
macros. The command is required to output json and should therefor
include --message-format=json
or a similar option.
By default, a cargo invocation will be constructed for the configured targets and features, with the following base command line:
cargo check --quiet --workspace --message-format=json --all-targets
.
key | value |
---|---|
items | {‘type’: ‘string’} |
type: boolean
default: True
Use
RUSTC_WRAPPER=rust-analyzer
when running build scripts to
avoid compiling unnecessary things.
default: []
anyOf:
{'type': 'string', 'enum': ['all'], 'enumDescriptions': ['Pass `--all-features` to cargo']}
{'type': 'array', 'items': {'type': 'string'}}
List of features to activate.
Set this to "all"
to pass --all-features
to
cargo.
type: boolean
default: False
Whether to pass
--no-default-features
to cargo.
type: boolean
default: False
Internal config for
debugging, disables loading of sysroot crates.
type: ['null', 'string']
Compilation target override (target triple).
type: array
default: ['core']
Unsets
#[cfg(test)]
for the specified crates.
key | value |
---|---|
items | {‘type’: ‘string’} |
type: boolean
default: True
Check all targets and
tests (--all-targets
).
type: string
default: check
Cargo command to use
for cargo check
.
type: boolean
default: True
Run specified
cargo check
command for diagnostics on save.
type: array
default: []
Extra arguments for
cargo check
.
key | value |
---|---|
items | {‘type’: ‘string’} |
anyOf:
{'type': 'string', 'enum': ['all'], 'enumDescriptions': ['Pass `--all-features` to cargo']}
{'type': 'array', 'items': {'type': 'string'}}
{'type': 'null'}
List of features to activate. Defaults to
#rust-analyzer.cargo.features#
.
Set to "all"
to pass --all-features
to
cargo.
type: ['null', 'boolean']
Whether
to pass --no-default-features
to cargo. Defaults to
#rust-analyzer.cargo.noDefaultFeatures#
.
type: ['null', 'array']
Override
the command rust-analyzer uses to run build scripts and build procedural
macros. The command is required to output json and should therefor
include --message-format=json
or a similar option.
An example command would be:
cargo check --workspace --message-format=json --all-targets
.
key | value |
---|---|
items | {‘type’: ‘string’} |
type: ['null', 'string']
Check for
a specific target. Defaults to
#rust-analyzer.cargo.target#
.
type: boolean
default: True
Toggles the additional
completions that automatically add imports when completed. Note that
your client must specify the additionalTextEdits
LSP client
capability to truly have this feature enabled.
type: boolean
default: True
Toggles the additional
completions that automatically show method calls and field accesses with
self
prefixed to them when inside a method.
type: string
default: fill_arguments
Whether to
add parenthesis and argument snippets when completing function.
value | description |
---|---|
fill_arguments | Add call parentheses and pre-fill arguments. |
add_parentheses | Add call parentheses. |
none | Do no snippet completions for callables. |
type: boolean
default: True
Whether to show postfix
snippets like dbg
, if
, not
,
etc.
type: boolean
default: False
Enables completions of
private items and fields that are defined in the current workspace even
if they are not visible at the current position.
type: object
default:
{
"Arc::new": {
"postfix": "arc",
"body": "Arc::new(${receiver})",
"requires": "std::sync::Arc",
"description": "Put the expression into an `Arc`",
"scope": "expr"
},
"Rc::new": {
"postfix": "rc",
"body": "Rc::new(${receiver})",
"requires": "std::rc::Rc",
"description": "Put the expression into an `Rc`",
"scope": "expr"
},
"Box::pin": {
"postfix": "pinbox",
"body": "Box::pin(${receiver})",
"requires": "std::boxed::Box",
"description": "Put the expression into a pinned `Box`",
"scope": "expr"
},
"Ok": {
"postfix": "ok",
"body": "Ok(${receiver})",
"description": "Wrap the expression in a `Result::Ok`",
"scope": "expr"
},
"Err": {
"postfix": "err",
"body": "Err(${receiver})",
"description": "Wrap the expression in a `Result::Err`",
"scope": "expr"
},
"Some": {
"postfix": "some",
"body": "Some(${receiver})",
"description": "Wrap the expression in an `Option::Some`",
"scope": "expr"
}
}
Custom completion snippets.
type: array
default: []
List of rust-analyzer
diagnostics to disable.
key | value |
---|---|
items | {‘type’: ‘string’} |
uniqueItems | True |
type: boolean
default: True
Whether to show native
rust-analyzer diagnostics.
type: boolean
default: False
Whether to show
experimental rust-analyzer diagnostics that might have more false
positives than usual.
type: object
default: {}
Map of prefixes to be
substituted when parsing diagnostic file paths. This should be the
reverse mapping of what is passed to rustc
as
--remap-path-prefix
.
type: array
default: []
List of warnings that
should be displayed with hint severity.
The warnings will be indicated by faded text or three dots in code
and will not show up in the Problems Panel
.
key | value |
---|---|
items | {‘type’: ‘string’} |
type: array
default: []
List of warnings that
should be displayed with info severity.
The warnings will be indicated by a blue squiggly underline in code
and a blue icon in the Problems Panel
.
key | value |
---|---|
items | {‘type’: ‘string’} |
type: array
default: []
These directories will be
ignored by rust-analyzer. They are relative to the workspace root, and
globs are not supported. You may also need to add the folders to Code’s
files.watcherExclude
.
key | value |
---|---|
items | {‘type’: ‘string’} |
type: string
default: client
Controls file
watching implementation.
type: boolean
default: True
Enables highlighting of
related references while the cursor is on break
,
loop
, while
, or for
keywords.
type: boolean
default: True
Enables highlighting of
all exit points while the cursor is on any return
,
?
, fn
, or return type arrow
(->
).
type: boolean
default: True
Enables highlighting of
related references while the cursor is on any identifier.
type: boolean
default: True
Enables highlighting of
all break points for a loop or block context while the cursor is on any
async
or await
keywords.
type: boolean
default: True
Whether to show
Debug
action. Only applies when
#rust-analyzer.hover.actions.enable#
is set.
type: boolean
default: True
Whether to show
HoverActions in Rust files.
type: boolean
default: True
Whether to show
Go to Type Definition
action. Only applies when
#rust-analyzer.hover.actions.enable#
is set.
type: boolean
default: True
Whether to show
Implementations
action. Only applies when
#rust-analyzer.hover.actions.enable#
is set.
type: boolean
default: False
Whether to show
References
action. Only applies when
#rust-analyzer.hover.actions.enable#
is set.
type: boolean
default: True
Whether to show
Run
action. Only applies when
#rust-analyzer.hover.actions.enable#
is set.
type: boolean
default: True
Whether to show
documentation on hover.
type: boolean
default: True
Use markdown syntax for
links in hover.
type: boolean
default: False
Whether to enforce the
import granularity setting for all files. If set to false rust-analyzer
will try to keep import styles consistent per file.
type: string
default: crate
How imports should be
grouped into use statements.
value | description |
---|---|
preserve | Do not change the granularity of any imports and preserve the original structure written by the developer. |
crate | Merge imports from the same crate into a single use statement. Conversely, imports from different crates are split into separate statements. |
module | Merge imports from the same module into a single use statement. Conversely, imports from different modules are split into separate statements. |
item | Flatten imports so that each has its own use statement. |
type: boolean
default: True
Group inserted imports
by the following
order. Groups are separated by newlines.
type: boolean
default: True
Whether to allow import
insertion to merge new imports into single path glob imports like
use std::fmt::*;
.
type: string
default: plain
The path structure for
newly inserted paths to use.
value | description |
---|---|
plain | Insert import paths relative to the
current module, using up to one super prefix if the parent
module contains the requested item. |
self | Insert import paths relative to the
current module, using up to one super prefix if the parent
module contains the requested item. Prefixes self in front
of the path if it starts with a module. |
crate | Force import paths to be absolute by
always starting them with crate or the extern crate name
they come from. |
type: boolean
default: False
Whether to show inlay
type hints for binding modes.
type: boolean
default: True
Whether to show inlay
type hints for method chains.
type: boolean
default: True
Whether to show inlay
hints after a closing }
to indicate what item it belongs
to.
type: integer
default: 25
minimum:
0
Minimum number of lines required before the
}
until the hint is shown (set to 0 or 1 to always show
them).
type: string
default: never
Whether to show inlay
type hints for return types of closures.
value | description |
---|---|
always | Always show type hints for return types of closures. |
never | Never show type hints for return types of closures. |
with_block | Only show type hints for return types of closures with blocks. |
type: string
default: never
Whether to show inlay
type hints for elided lifetimes in function signatures.
value | description |
---|---|
always | Always show lifetime elision hints. |
never | Never show lifetime elision hints. |
skip_trivial | Only show lifetime elision hints if a return type is involved. |
type: boolean
default: False
Whether to prefer
using parameter names as the name for elided lifetime hints if
possible.
type: ['null', 'integer']
default: 25
minimum:
0
Maximum length for inlay hints. Set to null to have
an unlimited length.
type: boolean
default: True
Whether to show
function parameter name inlay hints at the call site.
type: string
default: never
Whether to show inlay
type hints for compiler inserted reborrows.
value | description |
---|---|
always | Always show reborrow hints. |
never | Never show reborrow hints. |
mutable | Only show mutable reborrow hints. |
type: boolean
default: True
Whether to render
leading colons for type hints, and trailing colons for parameter
hints.
type: boolean
default: True
Whether to show inlay
type hints for variables.
type: boolean
default: False
Whether to hide inlay
type hints for let
statements that initialize to a closure.
Only applies to closures with blocks, same as
#rust-analyzer.inlayHints.closureReturnTypeHints.enable#
.
type: boolean
default: False
Whether to hide inlay
type hints for constructors.
type: boolean
default: True
Join lines merges
consecutive declaration and initialization of an assignment.
type: boolean
default: True
Join lines inserts else
between consecutive ifs.
type: boolean
default: True
Join lines removes
trailing commas.
type: boolean
default: True
Join lines unwraps
trivial blocks.
type: boolean
default: True
Whether to show
Debug
lens. Only applies when
#rust-analyzer.lens.enable#
is set.
type: boolean
default: True
Whether to show
CodeLens in Rust files.
type: boolean
default: True
Internal config: use
custom client-side commands even when the client doesn’t set the
corresponding capability.
type: boolean
default: True
Whether to show
Implementations
lens. Only applies when
#rust-analyzer.lens.enable#
is set.
type: boolean
default: False
Whether to show
References
lens for Struct, Enum, and Union. Only applies
when #rust-analyzer.lens.enable#
is set.
type: boolean
default: False
Whether to show
References
lens for Enum Variants. Only applies when
#rust-analyzer.lens.enable#
is set.
type: boolean
default: False
Whether to show
Method References
lens. Only applies when
#rust-analyzer.lens.enable#
is set.
type: boolean
default: False
Whether to show
References
lens for Trait. Only applies when
#rust-analyzer.lens.enable#
is set.
type: boolean
default: True
Whether to show
Run
lens. Only applies when
#rust-analyzer.lens.enable#
is set.
type: array
default: []
Disable project
auto-discovery in favor of explicitly specified set of projects.
Elements must be paths pointing to Cargo.toml
,
rust-project.json
, or JSON objects in
rust-project.json
format.
key | value |
---|---|
items | {‘type’: [‘string’, ‘object’]} |
type: ['null', 'integer']
minimum: 0
Number of syntax trees
rust-analyzer keeps in memory. Defaults to 128.
type: boolean
default: True
Whether to show
can't find Cargo.toml
error message.
type: boolean
default: True
Expand attribute
macros. Requires #rust-analyzer.procMacro.enable#
to be
set.
type: boolean
default: True
Enable support for
procedural macros, implies
#rust-analyzer.cargo.buildScripts.enable#
.
type: object
default: {}
These proc-macros will be
ignored when trying to expand them.
This config takes a map of crate names with the exported proc-macro names to ignore as values.
type: ['null', 'string']
Internal
config, path to proc-macro server executable (typically, this is
rust-analyzer itself, but we override this in tests).
type: ['null', 'string']
Command
to be executed instead of ‘cargo’ for runnables.
type: array
default: []
Additional arguments to
be passed to cargo for runnables such as tests or binaries. For example,
it may be --release
.
key | value |
---|---|
items | {‘type’: ‘string’} |
type: ['null', 'string']
Path to
the Cargo.toml of the rust compiler workspace, for usage in
rustc_private projects, or “discover” to try to automatically find it if
the rustc-dev
component is installed.
Any project which uses rust-analyzer with the rustcPrivate crates
must set
[package.metadata.rust-analyzer] rustc_private=true
to use
it.
This option does not take effect until rust-analyzer is restarted.
type: array
default: []
Additional arguments to
rustfmt
.
key | value |
---|---|
items | {‘type’: ‘string’} |
type: ['null', 'array']
Advanced
option, fully override the command rust-analyzer uses for
formatting.
key | value |
---|---|
items | {‘type’: ‘string’} |
type: boolean
default: False
Enables the use of
rustfmt’s unstable range formatting command for the
textDocument/rangeFormatting
request. The rustfmt option is
unstable and only available on a nightly build.
type: boolean
default: True
Use semantic tokens for
strings.
In some editors (e.g. vscode) semantic tokens override other highlighting grammars. By disabling semantic tokens for strings, other grammars can be used to highlight their contents.
type: string
default: full
Show full signature of
the callable. Only shows parameters if disabled.
value | description |
---|---|
full | Show the entire signature. |
parameters | Show only the parameters. |
type: boolean
default: True
Show documentation.
type: boolean
default: False
Whether to insert
closing angle brackets when typing an opening angle bracket of a generic
argument list.
type: string
default: only_types
Workspace symbol
search kind.
value | description |
---|---|
only_types | Search for types only. |
all_symbols | Search for all symbols kinds. |
type: integer
default: 128
minimum: 0
Limits the number of items
returned from a workspace symbol search (Defaults to 128). Some clients
like vs-code issue new searches on result filtering and don’t require
all results to be returned in the initial search. Other clients requires
all results upfront and might require a higher limit.
type: string
default: workspace
Workspace symbol
search scope.
value | description |
---|---|
workspace | Search in current workspace only. |
workspace_and_dependencies | Search in current workspace and dependencies. |
type: boolean
default: False
Whether to restart the
server automatically when certain settings that require a restart are
changed.