Reference Documentation for Rust Analyzer Options

2021-10-04

Rust Analyzer Options

TOC

Rust Analyzer

Rust Analyzer {#configuration_Rust Analyzer}

rust-analyzer.cargoRunner

type: ['null', 'string']
Custom cargo runner extension ID.

rust-analyzer.runnableEnv

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.

rust-analyzer.inlayHints.enable

type: boolean
default: True
Whether to show inlay hints.

rust-analyzer.inlayHints.smallerHints

type: boolean
default: True
Whether inlay hints font size should be smaller than editor’s font size.

rust-analyzer.updates.channel

type: string
default: stable
Choose nightly updates to get the latest features and bug fixes every day. While stable releases occur weekly and don’t contain cutting-edge features from VSCode proposed APIs.

possible values

value description
stable stable updates are shipped weekly, they don’t contain cutting-edge features from VSCode proposed APIs but have less bugs in general.
nightly nightly updates are shipped daily (extension updates automatically by downloading artifacts directly from GitHub), they contain cutting-edge features and latest bug fixes. These releases help us get your feedback very quickly and speed up rust-analyzer development drastically.

rust-analyzer.updates.askBeforeDownload

type: boolean
default: False
Whether to ask for permission before downloading any files from the Internet.

rust-analyzer.server.path

type: ['null', 'string']
Path to rust-analyzer executable (points to bundled binary by default). If this is set, then #rust-analyzer.updates.channel# setting is not used

key value
scope machine-overridable

rust-analyzer.server.extraEnv

type: ['null', 'object']
Extra environment variables that will be passed to the rust-analyzer executable. Useful for passing e.g. RA_LOG for debugging.

rust-analyzer.trace.server

type: string
default: off
Trace requests to the rust-analyzer (this is usually overly verbose and not recommended for regular users).

possible values

value description
off No traces
messages Error only
verbose Full log
key value
scope window

rust-analyzer.trace.extension

type: boolean
default: False
Enable logging of VS Code extensions itself.

rust-analyzer.debug.engine

type: string
default: auto
Preferred debug engine.

possible values

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

rust-analyzer.debug.sourceFileMap

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

rust-analyzer.debug.openDebugPane

type: boolean
default: False
Whether to open up the Debug Panel on debugging start.

rust-analyzer.debug.engineSettings

type: object
default: {}
Optional settings passed to the debug engine. Example: { "lldb": { "terminal":"external"} }

rust-analyzer.assist.importGranularity

type: string
default: crate
How imports should be grouped into use statements.

possible values

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.

rust-analyzer.assist.importEnforceGranularity

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.

rust-analyzer.assist.importPrefix

type: string
default: plain
The path structure for newly inserted paths to use.

possible values

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.

rust-analyzer.assist.importGroup

type: boolean
default: True
Group inserted imports by the https://rust-analyzer.github.io/manual.html#auto-import[following order]. Groups are separated by newlines.

rust-analyzer.assist.allowMergingIntoGlobImports

type: boolean
default: True
Whether to allow import insertion to merge new imports into single path glob imports like use std::fmt::*;.

rust-analyzer.callInfo.full

type: boolean
default: True
Show function name and docs in parameter hints.

rust-analyzer.cargo.autoreload

type: boolean
default: True
Automatically refresh project info via cargo metadata on Cargo.toml changes.

rust-analyzer.cargo.allFeatures

type: boolean
default: False
Activate all available features (--all-features).

rust-analyzer.cargo.unsetTest

type: array
default: ['core']
Unsets #[cfg(test)] for the specified crates.

key value
items {‘type’: ‘string’}

rust-analyzer.cargo.features

type: array
default: []
List of features to activate.

key value
items {‘type’: ‘string’}

rust-analyzer.cargo.runBuildScripts

type: boolean
default: True
Run build scripts (build.rs) for more precise code analysis.

rust-analyzer.cargo.useRustcWrapperForBuildScripts

type: boolean
default: True
Use RUSTC_WRAPPER=rust-analyzer when running build scripts to avoid compiling unnecessary things.

rust-analyzer.cargo.noDefaultFeatures

type: boolean
default: False
Do not activate the default feature.

rust-analyzer.cargo.target

type: ['null', 'string']
Compilation target (target triple).

rust-analyzer.cargo.noSysroot

type: boolean
default: False
Internal config for debugging, disables loading of sysroot crates.

rust-analyzer.checkOnSave.enable

type: boolean
default: True
Run specified cargo check command for diagnostics on save.

rust-analyzer.checkOnSave.allFeatures

type: ['null', 'boolean']
Check with all features (--all-features). Defaults to #rust-analyzer.cargo.allFeatures#.

rust-analyzer.checkOnSave.allTargets

type: boolean
default: True
Check all targets and tests (--all-targets).

rust-analyzer.checkOnSave.command

type: string
default: check
Cargo command to use for cargo check.

rust-analyzer.checkOnSave.noDefaultFeatures

type: ['null', 'boolean']
Do not activate the default feature.

rust-analyzer.checkOnSave.target

type: ['null', 'string']
Check for a specific target. Defaults to #rust-analyzer.cargo.target#.

rust-analyzer.checkOnSave.extraArgs

type: array
default: []
Extra arguments for cargo check.

key value
items {‘type’: ‘string’}

rust-analyzer.checkOnSave.features

type: ['null', 'array']
List of features to activate. Defaults to #rust-analyzer.cargo.features#.

key value
items {‘type’: ‘string’}

rust-analyzer.checkOnSave.overrideCommand

type: ['null', 'array']
Advanced option, fully override the command rust-analyzer uses for checking. The command should include --message-format=json or similar option.

key value
items {‘type’: ‘string’}

rust-analyzer.completion.addCallArgumentSnippets

type: boolean
default: True
Whether to add argument snippets when completing functions. Only applies when #rust-analyzer.completion.addCallParenthesis# is set.

rust-analyzer.completion.addCallParenthesis

type: boolean
default: True
Whether to add parenthesis when completing functions.

rust-analyzer.completion.postfix.enable

type: boolean
default: True
Whether to show postfix snippets like dbg, if, not, etc.

rust-analyzer.completion.autoimport.enable

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.

rust-analyzer.completion.autoself.enable

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.

rust-analyzer.diagnostics.enable

type: boolean
default: True
Whether to show native rust-analyzer diagnostics.

rust-analyzer.diagnostics.enableExperimental

type: boolean
default: True
Whether to show experimental rust-analyzer diagnostics that might have more false positives than usual.

rust-analyzer.diagnostics.disabled

type: array
default: []
List of rust-analyzer diagnostics to disable.

key value
items {‘type’: ‘string’}
uniqueItems True

rust-analyzer.diagnostics.remapPrefix

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.

rust-analyzer.diagnostics.warningsAsHint

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’}

rust-analyzer.diagnostics.warningsAsInfo

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’}

rust-analyzer.experimental.procAttrMacros

type: boolean
default: True
Expand attribute macros.

rust-analyzer.files.watcher

type: string
default: client
Controls file watching implementation.

rust-analyzer.files.excludeDirs

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’}

rust-analyzer.highlightRelated.references

type: boolean
default: True
Enables highlighting of related references while hovering your mouse above any identifier.

rust-analyzer.highlightRelated.exitPoints

type: boolean
default: True
Enables highlighting of all exit points while hovering your mouse above any return, ?, or return type arrow (->).

rust-analyzer.highlightRelated.breakPoints

type: boolean
default: True
Enables highlighting of related references while hovering your mouse break, loop, while, or for keywords.

rust-analyzer.highlightRelated.yieldPoints

type: boolean
default: True
Enables highlighting of all break points for a loop or block context while hovering your mouse above any async or await keywords.

rust-analyzer.highlighting.strings

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.

rust-analyzer.hover.documentation

type: boolean
default: True
Whether to show documentation on hover.

rust-analyzer.hover.linksInHover

type: boolean
default: True
Use markdown syntax for links in hover.

rust-analyzer.hoverActions.debug

type: boolean
default: True
Whether to show Debug action. Only applies when #rust-analyzer.hoverActions.enable# is set.

rust-analyzer.hoverActions.enable

type: boolean
default: True
Whether to show HoverActions in Rust files.

rust-analyzer.hoverActions.gotoTypeDef

type: boolean
default: True
Whether to show Go to Type Definition action. Only applies when #rust-analyzer.hoverActions.enable# is set.

rust-analyzer.hoverActions.implementations

type: boolean
default: True
Whether to show Implementations action. Only applies when #rust-analyzer.hoverActions.enable# is set.

rust-analyzer.hoverActions.references

type: boolean
default: False
Whether to show References action. Only applies when #rust-analyzer.hoverActions.enable# is set.

rust-analyzer.hoverActions.run

type: boolean
default: True
Whether to show Run action. Only applies when #rust-analyzer.hoverActions.enable# is set.

rust-analyzer.inlayHints.chainingHints

type: boolean
default: True
Whether to show inlay type hints for method chains.

rust-analyzer.inlayHints.maxLength

type: ['null', 'integer']
default: 25
minimum: 0
Maximum length for inlay hints. Set to null to have an unlimited length.

rust-analyzer.inlayHints.parameterHints

type: boolean
default: True
Whether to show function parameter name inlay hints at the call site.

rust-analyzer.inlayHints.typeHints

type: boolean
default: True
Whether to show inlay type hints for variables.

rust-analyzer.joinLines.joinElseIf

type: boolean
default: True
Join lines inserts else between consecutive ifs.

rust-analyzer.joinLines.removeTrailingComma

type: boolean
default: True
Join lines removes trailing commas.

rust-analyzer.joinLines.unwrapTrivialBlock

type: boolean
default: True
Join lines unwraps trivial blocks.

rust-analyzer.joinLines.joinAssignments

type: boolean
default: True
Join lines merges consecutive declaration and initialization of an assignment.

rust-analyzer.lens.debug

type: boolean
default: True
Whether to show Debug lens. Only applies when #rust-analyzer.lens.enable# is set.

rust-analyzer.lens.enable

type: boolean
default: True
Whether to show CodeLens in Rust files.

rust-analyzer.lens.implementations

type: boolean
default: True
Whether to show Implementations lens. Only applies when #rust-analyzer.lens.enable# is set.

rust-analyzer.lens.run

type: boolean
default: True
Whether to show Run lens. Only applies when #rust-analyzer.lens.enable# is set.

rust-analyzer.lens.methodReferences

type: boolean
default: False
Whether to show Method References lens. Only applies when #rust-analyzer.lens.enable# is set.

rust-analyzer.lens.references

type: boolean
default: False
Whether to show References lens. Only applies when #rust-analyzer.lens.enable# is set.

rust-analyzer.lens.forceCustomCommands

type: boolean
default: True
Internal config: use custom client-side commands even when the client doesn’t set the corresponding capability.

rust-analyzer.linkedProjects

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’]}

rust-analyzer.lruCapacity

type: ['null', 'integer']
minimum: 0
Number of syntax trees rust-analyzer keeps in memory. Defaults to 128.

rust-analyzer.notifications.cargoTomlNotFound

type: boolean
default: True
Whether to show can't find Cargo.toml error message.

rust-analyzer.procMacro.enable

type: boolean
default: True
Enable support for procedural macros, implies #rust-analyzer.cargo.runBuildScripts#.

rust-analyzer.procMacro.server

type: ['null', 'string']
Internal config, path to proc-macro server executable (typically, this is rust-analyzer itself, but we override this in tests).

rust-analyzer.runnables.overrideCargo

type: ['null', 'string']
Command to be executed instead of ‘cargo’ for runnables.

rust-analyzer.runnables.cargoExtraArgs

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’}

rust-analyzer.rustcSource

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.

Any project which uses rust-analyzer with the rustcPrivate crates must set [package.metadata.rust-analyzer] rustc_private=true to use it.

This option is not reloaded automatically; you must restart rust-analyzer for it to take effect.

rust-analyzer.rustfmt.extraArgs

type: array
default: []
Additional arguments to rustfmt.

key value
items {‘type’: ‘string’}

rust-analyzer.rustfmt.overrideCommand

type: ['null', 'array']
Advanced option, fully override the command rust-analyzer uses for formatting.

key value
items {‘type’: ‘string’}

rust-analyzer.rustfmt.enableRangeFormatting

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.

rust-analyzer.workspace.symbol.search.scope

type: string
default: workspace
Workspace symbol search scope.

possible values

value description
workspace Search in current workspace only
workspace_and_dependencies Search in current workspace and dependencies

rust-analyzer.workspace.symbol.search.kind

type: string
default: only_types
Workspace symbol search kind.

possible values

value description
only_types Search for types only
all_symbols Search for all symbols kinds