2025-11-17
Rust Analyzer Options
type: boolean
default: False Restart the server
automatically when settings that require a restart are changed.
type: boolean
default: True Show a notification for
unlinked files, prompting the user to add the corresponding Cargo.toml
to the linked projects setting.
type: boolean
default: True Show error
notifications when requests fail.
type: boolean
default: True Show Rust Dependencies
in the Explorer view.
type: boolean
default: False Show Syntax Tree in
the Explorer view.
type: boolean
default: False Show the Test Explorer
view.
type: boolean
default: False Do not start
rust-analyzer server when the extension is activated.
type: boolean
default: True Run the check command
for diagnostics on save.
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, .rs files (which will be
treated as standalone files) or JSON objects in
rust-project.json format.
| key | value |
|---|---|
| items | {‘type’: [‘string’, ‘object’]} |
anyOf:
{'type': 'null'}
{'type': 'number', 'minimum': 0, 'maximum': 255}
{'type': 'string', 'enum': ['physical', 'logical'], 'enumDescriptions': ['Use the number of physical cores', 'Use the number of logical cores']}
The number of worker threads in the main loop. The default
null means to pick automatically.
anyOf:
{'type': 'null'}
{'type': 'array', 'items': {'type': 'object', 'properties': {'platform': {'type': ['null', 'string', 'array'], 'default': None, 'markdownDescription': 'Platform(s) filter like "win32" or ["linux", "win32"]. See [process.platform](https://nodejs.org/api/process.html#processplatform) values.'}, '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: array
default: ['$rustc'] Problem matchers
to use for rust-analyzer.run command, eg
["$rustc", "$rust-panic"].
| key | value |
|---|---|
| items | {‘type’: ‘string’} |
type: boolean
default: True Ask before updating the
test when running it.
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: array
default: ['--nocapture'] Additional
arguments to be passed through Cargo to launched tests, benchmarks, or
doc-tests.
Unless the launched target uses a custom
test harness, they will end up being interpreted as options to rustc’s
built-in test harness (“libtest”).
| key | value |
|---|---|
| items | {‘type’: ‘string’} |
type: string
default: openLogs Action to run when
clicking the extension status bar item.
| value | description |
|---|---|
| stopServer | Stop Server |
| openLogs | Open Logs |
default:
{
"documentSelector": [
{
"language": "rust"
},
{
"pattern": "**/Cargo.toml"
},
{
"pattern": "**/Cargo.lock"
},
{
"scheme": "output",
"pattern": "extension-output-rust-lang.rust-analyzer*"
}
]
}anyOf:
{'type': 'string', 'enum': ['always', 'never']}
{'type': 'object', 'properties': {'documentSelector': {'type': 'array', 'items': {'type': 'object', 'properties': {'language': {'type': 'string'}, 'notebookType': {'type': 'string'}, 'scheme': {'type': 'string'}, 'pattern': {'type': 'string'}}}}}}
When to show the extension status bar.
"always" Always show the status bar.
"never" Never show the status bar.
{ documentSelector: <DocumentSelector>[] } Show
the status bar if the open file matches any of the given document
selectors.
See VS Code – DocumentSelector for more information.
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’, ‘null’]} |
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.
| key | value |
|---|---|
| markdownDeprecationMessage | Log level is now controlled by the Developer: Set Log Level… command.You can set the log level for the current session and also the default log level from there. This is also available by clicking the gear icon on the OUTPUT tab when Rust Analyzer Client is visible or by passing the –log rust-lang.rust-analyzer:debug parameter to VS Code. |
type: string
default: auto Preferred debug
engine.
| value | description |
|---|---|
| auto | Use the first available extension out of LLDB DAP, CodeLLDB, C/C++ for Visual Studio Code, and Native Debug. |
| llvm-vs-code-extensions.lldb-dap | Use LLDB DAP |
| vadimcn.vscode-lldb | Use CodeLLDB |
| ms-vscode.cpptools | Use C/C++ for Visual Studio Code |
| webfreak.debug | Use Native Debug |
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 rebuild the
project modules before debugging the same test again
type: object
default: {} Optional settings passed
to the debug engine. Example:
{ "lldb": { "terminal":"external"} }
type: boolean
default: True Whether to prefix
newlines after comments with the corresponding comment prefix.
type: ['null', 'string']
default: =. Specify the characters
allowed to invoke special on typing triggers.
= after let tries to smartly add
; if = is followed by an existing
expression= between two expressions adds ;
when in statement position= to turn an assignment into an equality
comparison removes ; when in expression position. in a chain method call auto-indents{ or ( in front of an expression
inserts a closing } or ) after the
expression{ in a use item adds a closing } in
the right place> to complete a return type
-> will insert a whitespace after it< in a path or type position inserts a
closing > after the path or type.type: boolean
default: False Whether to show the
main part of the rendered rustc output of a diagnostic message.
type: boolean
default: False Whether to show
diagnostics using the original rustc error code. If this is false, all
rustc diagnostics will have the code ‘rustc(Click for full compiler
diagnostics)’
type: array
default: [] List of rust-analyzer
diagnostics to disable.
| key | value |
|---|---|
| items | {‘type’: ‘string’} |
| uniqueItems | True |
type: boolean
default: True Show native
rust-analyzer diagnostics.
type: boolean
default: False 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: boolean
default: False Run additional style
lints.
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: boolean
default: False Insert #[must_use]
when generating as_ methods for enum variants.
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: False Prefer to use
Self over the type name when inserting a type (e.g. in
“fill match arms” assist).
type: boolean
default: True Enable borrow checking
for term search code assists. If set to false, also there will be more
suggestions, but some of them may not borrow-check.
type: integer
default: 1800
minimum: 0 Term search fuel in “units
of work” for assists (Defaults to 1800).
type: boolean
default: True Warm up caches on
project load.
default: physical
anyOf:
{'type': 'number', 'minimum': 0, 'maximum': 255}
{'type': 'string', 'enum': ['physical', 'logical'], 'enumDescriptions': ['Use the number of physical cores', 'Use the number of logical cores']}
How many worker threads to handle priming caches. The default
0 means to pick automatically.
type: boolean
default: True Pass
--all-targets to cargo invocation.
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: string
default: per_workspace Specifies the
invocation strategy to use when running the build scripts command. If
per_workspace is set, the command will be executed for each
Rust workspace with the workspace as the working directory. If
once is set, the command will be executed once with the
opened project as the working directory. This config only has an effect
when #rust-analyzer.cargo.buildScripts.overrideCommand# is
set.
| value | description |
|---|---|
| per_workspace | The command will be executed for each Rust workspace with the workspace as the working directory. |
| once | The command will be executed once with the opened project as the working directory. |
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 therefore
include --message-format=json or a similar option.
If there are multiple linked projects/workspaces, this command is
invoked for each of them, with the working directory being the workspace
root (i.e., the folder containing the Cargo.toml). This can
be overwritten by changing
#rust-analyzer.cargo.buildScripts.invocationStrategy#.
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 --keep-goingNote: The option must be specified as an array of command line arguments, with the first argument being the name of the command to run.
| key | value |
|---|---|
| items | {‘type’: ‘string’} |
type: boolean
default: True Rerun proc-macros
building/build-scripts running when proc-macro or build-script sources
change and are saved.
type: boolean
default: True Use
RUSTC_WRAPPER=rust-analyzer when running build scripts to
avoid checking unnecessary things.
type: array
default: ['debug_assertions', 'miri']
List of cfg options to enable with the given values.
To enable a name without a value, use "key". To enable a
name with a value, use "key=value". To disable, prefix the
entry with a !.
| key | value |
|---|---|
| items | {‘type’: ‘string’} |
type: array
default: [] Extra arguments that are
passed to every cargo invocation.
| key | value |
|---|---|
| items | {‘type’: ‘string’} |
type: object
default: {} Extra environment
variables that will be set when running cargo, rustc or other commands
within the workspace. Useful for setting RUSTFLAGS.
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 Whether to skip
fetching dependencies. If set to “true”, the analysis is performed
entirely offline, and Cargo metadata for dependencies is not
fetched.
type: ['null', 'string']
default: discover Relative path to
the sysroot, or “discover” to try to automatically find it via “rustc
–print sysroot”.
Unsetting this disables sysroot loading.
This option does not take effect until rust-analyzer is restarted.
type: ['null', 'string'] Relative
path to the sysroot library sources. If left unset, this will default to
{cargo.sysroot}/lib/rustlib/src/rust/library.
This option does not take effect until rust-analyzer is restarted.
type: ['null', 'string']
Compilation target override (target tuple).
anyOf:
{'type': 'null'}
{'type': 'boolean'}
{'type': 'string'}
Optional path to a rust-analyzer specific target directory. This
prevents rust-analyzer’s cargo check and initial
build-script and proc-macro building from locking the
Cargo.lock at the expense of duplicating build
artifacts.
Set to true to use a subdirectory of the existing target
directory or set to a path relative to the workspace to use that
path.
type: boolean
default: True Set
cfg(test) for local crates. Defaults to true.
type: ['null', 'boolean'] Check
all targets and tests (--all-targets). Defaults to
#rust-analyzer.cargo.allTargets#.
type: string
default: check Cargo command to use
for cargo check.
type: array
default: [] Extra arguments for
cargo check.
| key | value |
|---|---|
| items | {‘type’: ‘string’} |
type: object
default: {} Extra environment
variables that will be set when running cargo check.
Extends #rust-analyzer.cargo.extraEnv#.
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: array
default: [] List of
cargo check (or other command specified in
check.command) diagnostics to ignore.
For example for cargo check: dead_code,
unused_imports, unused_variables,…
| key | value |
|---|---|
| items | {‘type’: ‘string’} |
| uniqueItems | True |
type: string
default: per_workspace Specifies the
invocation strategy to use when running the check command. If
per_workspace is set, the command will be executed for each
workspace. If once is set, the command will be executed
once. This config only has an effect when
#rust-analyzer.check.overrideCommand# is set.
| value | description |
|---|---|
| per_workspace | The command will be executed for each Rust workspace with the workspace as the working directory. |
| once | The command will be executed once with the opened project as the working directory. |
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 instead of cargo check for
diagnostics on save. The command is required to output json and should
therefore include --message-format=json or a similar option
(if your client supports the colorDiagnosticOutput
experimental capability, you can use
--message-format=json-diagnostic-rendered-ansi).
If you’re changing this because you’re using some tool wrapping
Cargo, you might also want to change
#rust-analyzer.cargo.buildScripts.overrideCommand#.
If there are multiple linked projects/workspaces, this command is
invoked for each of them, with the working directory being the workspace
root (i.e., the folder containing the Cargo.toml). This can
be overwritten by changing
#rust-analyzer.check.invocationStrategy#.
If $saved_file is part of the command, rust-analyzer
will pass the absolute path of the saved file to the provided command.
This is intended to be used with non-Cargo build systems. Note that
$saved_file is experimental and may be removed in the
future.
An example command would be:
cargo check --workspace --message-format=json --all-targetsNote: The option must be specified as an array of command line arguments, with the first argument being the name of the command to run.
| key | value |
|---|---|
| items | {‘type’: ‘string’} |
anyOf:
{'type': 'null'}
{'type': 'string'}
{'type': 'array', 'items': {'type': 'string'}}
Check for specific targets. Defaults to
#rust-analyzer.cargo.target# if empty.
Can be a single target, e.g. "x86_64-unknown-linux-gnu"
or a list of targets, e.g.
["aarch64-apple-darwin", "x86_64-apple-darwin"].
Aliased as "checkOnSave.targets".
type: boolean
default: True Whether
--workspace should be passed to cargo check.
If false, -p <package> will be passed instead if
applicable. In case it is not, no check will be performed.
type: boolean
default: True Automatically add a
semicolon when completing unit-returning functions.
In match arms it completes a comma instead.
type: boolean
default: True Show method calls and
field accesses completions with await prefixed to them when
completing on a future.
type: boolean
default: True Show method call
completions with iter() or into_iter()
prefixed to them when completing on a type that has them.
type: boolean
default: True Show 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: array
default:
[{'path': 'core::borrow::Borrow', 'type': 'methods'}, {'path': 'core::borrow::BorrowMut', 'type': 'methods'}]
A list of full paths to items to exclude from auto-importing
completions.
Traits in this list won’t have their methods suggested in completions unless the trait is in scope.
You can either specify a string path which defaults to type “always”
or use the more verbose form
{ "path": "path::to::item", type: "always" }.
For traits the type “methods” can be used to only exclude the methods but not the trait itself.
This setting also inherits
#rust-analyzer.completion.excludeTraits#.
| key | value |
|---|---|
| items | {‘anyOf’: [{‘type’: ‘string’}, {‘type’: ‘object’, ‘properties’: {‘path’: {‘type’: ‘string’}, ‘type’: {‘type’: ‘string’, ‘enum’: [‘always’, ‘methods’], ‘enumDescriptions’: [‘Do not show this item or its methods (if it is a trait) in auto-import completions.’, ‘Do not show this traits methods in auto-import completions.’]}}}]} |
type: boolean
default: True Show method calls and
field access completions with self prefixed to them when
inside a method.
type: string
default: fill_arguments 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: array
default: [] A list of full paths to
traits whose methods to exclude from completion.
Methods from these traits won’t be completed, even if the trait is in
scope. However, they will still be suggested on expressions whose type
is dyn Trait, impl Trait or
T where T: Trait.
Note that the trait themselves can still be completed.
| key | value |
|---|---|
| items | {‘type’: ‘string’} |
type: boolean
default: False Show full function /
method signatures in completion docs.
type: boolean
default: False Omit deprecated items
from completions. By default they are marked as deprecated but not
hidden.
type: ['null', 'integer']
minimum: 0 Maximum number of
completions to return. If None, the limit is infinite.
type: boolean
default: True Show postfix snippets
like dbg, if, not, etc.
type: boolean
default: False Show 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:
{
"Ok": {
"postfix": "ok",
"body": "Ok(${receiver})",
"description": "Wrap the expression in a `Result::Ok`",
"scope": "expr"
},
"Box::pin": {
"postfix": "pinbox",
"body": "Box::pin(${receiver})",
"requires": "std::boxed::Box",
"description": "Put the expression into a pinned `Box`",
"scope": "expr"
},
"Arc::new": {
"postfix": "arc",
"body": "Arc::new(${receiver})",
"requires": "std::sync::Arc",
"description": "Put the expression into an `Arc`",
"scope": "expr"
},
"Some": {
"postfix": "some",
"body": "Some(${receiver})",
"description": "Wrap the expression in an `Option::Some`",
"scope": "expr"
},
"Err": {
"postfix": "err",
"body": "Err(${receiver})",
"description": "Wrap the expression in a `Result::Err`",
"scope": "expr"
},
"Rc::new": {
"postfix": "rc",
"body": "Rc::new(${receiver})",
"requires": "std::rc::Rc",
"description": "Put the expression into an `Rc`",
"scope": "expr"
}
}Custom completion snippets.
type: boolean
default: False Enable term search
based snippets like Some(foo.bar().baz()).
type: integer
default: 1000
minimum: 0 Term search fuel in “units
of work” for autocompletion (Defaults to 1000).
type: boolean
default: True Exclude all locals from
document symbol search.
type: array
default: [] List of files to
ignore
These paths (file/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.
| value | description |
|---|---|
| client | Use the client (editor) to watch files for changes |
| server | Use server-side file watching |
type: boolean
default: False If this is
true, when “Goto Implementations” and in “Implementations”
lens, are triggered on a struct or enum or
union, we filter out trait implementations that originate
from derives above the type.
type: boolean
default: True Highlight related
return values while the cursor is on any match,
if, or match arm arrow (=>).
type: boolean
default: True Highlight related
references while the cursor is on break, loop,
while, or for keywords.
type: boolean
default: True Highlight all captures
of a closure while the cursor is on the | or move keyword
of a closure.
type: boolean
default: True Highlight all exit
points while the cursor is on any return, ?,
fn, or return type arrow (->).
type: boolean
default: True Highlight related
references while the cursor is on any identifier.
type: boolean
default: True Highlight all break
points for a loop or block context while the cursor is on any
async or await keywords.
type: boolean
default: True Show Debug
action. Only applies when
#rust-analyzer.hover.actions.enable# is set.
type: boolean
default: True Show HoverActions in
Rust files.
type: boolean
default: True Show
Go to Type Definition action. Only applies when
#rust-analyzer.hover.actions.enable# is set.
type: boolean
default: True Show
Implementations action. Only applies when
#rust-analyzer.hover.actions.enable# is set.
type: boolean
default: False Show
References action. Only applies when
#rust-analyzer.hover.actions.enable# is set.
type: boolean
default: True Show Run
action. Only applies when
#rust-analyzer.hover.actions.enable# is set.
type: boolean
default: True Show
Update Test action. Only applies when
#rust-analyzer.hover.actions.enable# and
#rust-analyzer.hover.actions.run.enable# are set.
type: boolean
default: True Show documentation on
hover.
type: boolean
default: True Show keyword hover
popups. Only applies when
#rust-analyzer.hover.documentation.enable# is set.
type: boolean
default: True Show drop glue
information on hover.
type: boolean
default: True Use markdown syntax for
links on hover.
default: 20
anyOf:
{'type': 'null'}
{'type': 'string', 'enum': ['hide']}
{'type': 'integer'}
Show what types are used as generic arguments in calls etc. on hover, and limit the max length to show such types, beyond which they will be shown with ellipsis.
This can take three values: null means “unlimited”, the
string "hide" means to not show generic substitutions at
all, and a number means to limit them to X characters.
The default is 20 characters.
default: hexadecimal
anyOf:
{'type': 'null'}
{'type': 'string', 'enum': ['both', 'decimal', 'hexadecimal'], 'enumDescriptions': ['Render as 12 (0xC)', 'Render as 12', 'Render as 0xC']}
How to render the align information in a memory layout hover.
type: boolean
default: True Show memory layout data
on hover.
type: ['null', 'boolean']
default: False How to render the
niche information in a memory layout hover.
default: hexadecimal
anyOf:
{'type': 'null'}
{'type': 'string', 'enum': ['both', 'decimal', 'hexadecimal'], 'enumDescriptions': ['Render as 12 (0xC)', 'Render as 12', 'Render as 0xC']}
How to render the offset information in a memory layout hover.
anyOf:
{'type': 'null'}
{'type': 'string', 'enum': ['both', 'decimal', 'hexadecimal'], 'enumDescriptions': ['Render as 12 (0xC)', 'Render as 12', 'Render as 0xC']}
How to render the padding information in a memory layout hover.
default: both
anyOf:
{'type': 'null'}
{'type': 'string', 'enum': ['both', 'decimal', 'hexadecimal'], 'enumDescriptions': ['Render as 12 (0xC)', 'Render as 12', 'Render as 0xC']}
How to render the size information in a memory layout hover.
type: ['null', 'integer']
default: 5 minimum:
0 How many variants of an enum to display when
hovering on. Show none if empty.
type: ['null', 'integer']
default: 5 minimum:
0 How many fields of a struct, variant or union to
display when hovering on. Show none if empty.
type: ['null', 'integer']
minimum: 0 How many associated items
of a trait to display when hovering a trait.
type: boolean
default: False 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
anyOf:
{'enum': ['crate', 'module', 'item', 'one'], 'enumDescriptions': ['Merge imports from the same crate into a single use statement. Conversely, imports from different crates are split into separate statements.', 'Merge imports from the same module into a single use statement. Conversely, imports from different modules are split into separate statements.', 'Flatten imports so that each has its own use statement.', 'Merge all imports into a single use statement as long as they have the same visibility and attributes.']}
{'enum': ['preserve'], 'enumDescriptions': ['Deprecated - unless `enforceGranularity` is `true`, the style of the current file is preferred over this setting. Behaves like `item`.'], 'deprecated': True}
How imports should be grouped into use statements.
type: boolean
default: True Group inserted imports
by the following
order. Groups are separated by newlines.
type: boolean
default: True Allow import insertion
to merge new imports into single path glob imports like
use std::fmt::*;.
type: boolean
default: False Prefer to
unconditionally use imports of the core and alloc crate, over the std
crate.
type: boolean
default: False Prefer import paths
containing a prelude module.
type: string
default: crate 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 Prefix external
(including std, core) crate imports with ::.
E.g. use ::std::io::Read;.
type: boolean
default: False Show inlay type hints
for binding modes.
type: boolean
default: True Show inlay type hints
for method chains.
type: boolean
default: True 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: boolean
default: False Show inlay hints for
closure captures.
type: string
default: never 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: impl_fn Closure notation in
type and chaining inlay hints.
| value | description |
|---|---|
| impl_fn | impl_fn:
impl FnMut(i32, u64) -> i8 |
| rust_analyzer | rust_analyzer:
|i32, u64| -> i8 |
| with_id | with_id:
{closure#14352}, where that id is the unique number of the
closure in r-a internals |
| hide | hide: Shows ...
for every closure type |
type: string
default: never Show enum variant
discriminant hints.
| value | description |
|---|---|
| always | Always show all discriminant hints. |
| never | Never show discriminant hints. |
| fieldless | Only show discriminant hints on fieldless enum variants. |
type: boolean
default: True Disable reborrows in
expression adjustments inlay hints.
Reborrows are a pair of a builtin deref then borrow,
i.e. &*. They are inserted by the compiler but are
mostly useless to the programmer.
Note: if the deref is not builtin (an overloaded deref), or the
borrow is &raw const/&raw mut, they
are not removed.
type: string
default: never Show inlay hints for
type adjustments.
| value | description |
|---|---|
| always | Always show all adjustment hints. |
| never | Never show adjustment hints. |
| reborrow | Only show auto borrow and dereference adjustment hints. |
type: boolean
default: False Hide inlay hints for
type adjustments outside of unsafe blocks.
type: string
default: prefix Show inlay hints as
postfix ops (.* instead of *, etc).
| value | description |
|---|---|
| prefix | Always show adjustment hints as prefix
(*expr). |
| postfix | Always show adjustment hints as postfix
(expr.*). |
| prefer_prefix | Show prefix or postfix depending on which uses less parenthesis, preferring prefix. |
| prefer_postfix | Show prefix or postfix depending on which uses less parenthesis, preferring postfix. |
type: boolean
default: True Show const generic
parameter name inlay hints.
type: boolean
default: False Show generic lifetime
parameter name inlay hints.
type: boolean
default: False Show generic type
parameter name inlay hints.
type: boolean
default: False Show implicit drop
hints.
type: boolean
default: False Show inlay hints for
the implied type parameter Sized bound.
type: string
default: never 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 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.
Note: This is mostly a hint, and we don’t guarantee to strictly follow the limit.
type: boolean
default: True Show function parameter
name inlay hints at the call site.
type: boolean
default: False Show exclusive range
inlay hints.
type: string
default: never Show inlay hints for
compiler inserted reborrows.
This setting is deprecated in favor of #rust-analyzer.inlayHints.expressionAdjustmentHints.enable#.
| 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 Show inlay type hints
for variables.
type: boolean
default: False 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 Hide inlay parameter
type hints for closures.
type: boolean
default: False Hide inlay type hints
for constructors.
type: boolean
default: False Enable the
experimental support for interpreting tests.
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 Show Debug
lens. Only applies when #rust-analyzer.lens.enable# is
set.
type: boolean
default: True Show CodeLens in Rust
files.
type: boolean
default: True Show
Implementations lens. Only applies when
#rust-analyzer.lens.enable# is set.
type: string
default: above_name Where to render
annotations.
| value | description |
|---|---|
| above_name | Render annotations above the name of the item. |
| above_whole_item | Render annotations above the whole item, including documentation comments and attributes. |
type: boolean
default: False Show
References lens for Struct, Enum, and Union. Only applies
when #rust-analyzer.lens.enable# is set.
type: boolean
default: False Show
References lens for Enum Variants. Only applies when
#rust-analyzer.lens.enable# is set.
type: boolean
default: False Show
Method References lens. Only applies when
#rust-analyzer.lens.enable# is set.
type: boolean
default: False Show
References lens for Trait. Only applies when
#rust-analyzer.lens.enable# is set.
type: boolean
default: True Show Run
lens. Only applies when #rust-analyzer.lens.enable# is
set.
type: boolean
default: True Show
Update Test lens. Only applies when
#rust-analyzer.lens.enable# and
#rust-analyzer.lens.run.enable# are set.
type: ['null', 'integer']
minimum: 0 maximum:
65535 Number of syntax trees rust-analyzer keeps in
memory. Defaults to 128.
type: object
default: {} The LRU capacity of the
specified queries.
type: boolean
default: True 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.
type: ['null', 'string'] The path
where to save memory profiling output.
Note: Memory profiling is not enabled by default in rust-analyzer builds, you need to build from source for it.
type: boolean
default: False Exclude imports from
find-all-references.
type: boolean
default: False Exclude tests from
find-all-references and call-hierarchy.
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.
This should be the equivalent of rustfmt here, and not that
of cargo fmt. The file contents will be passed on the
standard input and the formatted result will be read from the standard
output.
Note: The option must be specified as an array of command line arguments, with the first argument being the name of the command to run.
| 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
comments.
In some editors (e.g. vscode) semantic tokens override other highlighting grammars. By disabling semantic tokens for comments, other grammars can be used to highlight their contents.
type: boolean
default: True Inject additional
highlighting into doc comments.
When enabled, rust-analyzer will highlight rust source in doc comments as well as intra doc links.
type: boolean
default: True Emit non-standard
tokens and modifiers
When enabled, rust-analyzer will emit tokens and modifiers that are not part of the standard set of semantic tokens.
type: boolean
default: True Use semantic tokens for
operators.
When disabled, rust-analyzer will emit semantic tokens only for operator tokens when they are tagged with modifiers.
type: boolean
default: False Use specialized
semantic tokens for operators.
When enabled, rust-analyzer will emit special token types for
operator tokens instead of the generic operator token
type.
type: boolean
default: False Use semantic tokens
for punctuation.
When disabled, rust-analyzer will emit semantic tokens only for punctuation tokens when they are tagged with modifiers or have a special role.
type: boolean
default: False When enabled,
rust-analyzer will emit a punctuation semantic token for the
! of macro calls.
type: boolean
default: False Use specialized
semantic tokens for punctuation.
When enabled, rust-analyzer will emit special token types for
punctuation tokens instead of the generic punctuation token
type.
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: array
default: [] Additional paths to
include in the VFS. Generally for code that is generated or otherwise
managed by a build system outside of Cargo, though Cargo might be the
eventual consumer.
| key | value |
|---|---|
| items | {‘type’: ‘string’} |
anyOf:
{'type': 'null'}
{'type': 'object', 'properties': {'command': {'type': 'array', 'items': {'type': 'string'}}, 'progressLabel': {'type': 'string'}, 'filesToWatch': {'type': 'array', 'items': {'type': 'string'}}}}
Enables automatic discovery of projects using
[DiscoverWorkspaceConfig::command].
[DiscoverWorkspaceConfig] also requires setting
progress_label and files_to_watch.
progress_label is used for the title in progress
indicators, whereas files_to_watch is used to determine
which build system-specific files should be watched in order to reload
rust-analyzer.
Below is an example of a valid configuration:
"rust-analyzer.workspace.discoverConfig": {
"command": [
"rust-project",
"develop-json"
],
"progressLabel": "rust-analyzer",
"filesToWatch": [
"BUCK"
]
}DiscoverWorkspaceConfig::commandWarning: This format is provisional and subject to change.
[DiscoverWorkspaceConfig::command] must return
a JSON object corresponding to
DiscoverProjectData::Finished:
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(tag = "kind")]
#[serde(rename_all = "snake_case")]
enum DiscoverProjectData {
Finished { buildfile: Utf8PathBuf, project: ProjectJsonData },
Error { error: String, source: Option<String> },
Progress { message: String },
}
As JSON, DiscoverProjectData::Finished is:
{
// the internally-tagged representation of the enum.
"kind": "finished",
// the file used by a non-Cargo build system to define
// a package or target.
"buildfile": "rust-analyzer/BUILD",
// the contents of a rust-project.json, elided for brevity
"project": {
"sysroot": "foo",
"crates": []
}
}It is encouraged, but not required, to use the other variants on
DiscoverProjectData to provide a more polished end-user
experience.
DiscoverWorkspaceConfig::command may optionally
include an {arg}, which will be substituted with the
JSON-serialized form of the following enum:
#[derive(PartialEq, Clone, Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum DiscoverArgument {
Path(AbsPathBuf),
Buildfile(AbsPathBuf),
}
The JSON representation of DiscoverArgument::Path
is:
{
"path": "src/main.rs"
}Similarly, the JSON representation of
DiscoverArgument::Buildfile is:
{
"buildfile": "BUILD"
}DiscoverArgument::Path is used to find and generate a
rust-project.json, and therefore, a workspace, whereas
DiscoverArgument::buildfile is used to to update an
existing workspace. As a reference for implementors, buck2’s
rust-project will likely be useful:
https://github.com/facebook/buck2/tree/main/integrations/rust-project.
type: boolean
default: False Exclude all imports
from workspace symbol search.
In addition to regular imports (which are always excluded), this option removes public imports (better known as re-exports) and removes imports that rename the imported symbol.
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. |