Cargo Runner

April 28, 2025 · View on GitHub

Open VSX | Vscode Marketplace

Open VSX Downloads Vscode Marketplace



A Complementary Tool to rust-analyzer to streamline your Rust development and enhance your productivity.

cover

No unicorns or crabs were harmed during the creation of this tool.

Requirements

Usage

  1. Open a Rust file in VS Code
  2. Position your cursor within a function, struct, module, or other symbols
  3. Click on the CodeLens buttons that appear above the symbol (▶︎ Run, Debug, ▶︎ Run Test, etc.)
  4. Use Ctrl+R (Cmd+R on macOS) to quickly run the code at the cursor position

Configuration

You can configure the extension using the command palette:

Override Configuration Syntax

Use the override syntax for quick configuration changes:

  • Press Ctrl+Shift+R (Cmd+Shift+R on macOS).
  • Or, use Ctrl+Shift+P (Cmd+Shift+P on macOS) and type Cargo Runner: Override Config.

Edit Project Settings File

Directly edit project-specific settings:

  • Use Ctrl+Shift+P (Cmd+Shift+P on macOS) and type Cargo Runner: Edit Project Settings to access a dropdown list of settings files (cargo-runner-settings.json or .vscode/settings.json) you can manually edit.

Configuration Options (Override Syntax)

The following options can be used with the Cargo Runner: Override Config command:

OptionDescriptionProject SettingVSCode SettingExample
--featuresEnable specific featuresrunnables.extraArgsrust-analyzer.cargo.features--features=my-feature,another-feature
--no-default-featuresDisable default featuresrunnables.extraArgsrust-analyzer.cargo.noDefaultFeatures--no-default-features
--cargo-targetSet cargo targetrunnables.extraArgsrust-analyzer.cargo.target--cargo-target=wasm32-unknown-unknown
--targetSet target in extraArgsrunnables.extraArgsrust-analyzer.runnables.extraArgs--target=wasm32-unknown-unknown
--target-dirUse custom target directoryrunnables.extraArgsrust-analyzer.cargo.targetDir--target-dir
ENV_VAR=valueSet environment variablesrunnables.extraEnvrust-analyzer.runnables.extraEnvRUST_LOG=debug
#Delimiter for test binary argsrunnables.extraTestBinaryArgsrust-analyzer.runnables.extraTestBinaryArgs--release # --nocapture --exact
+channelSet Rust toolchain channelCreates rust-toolchain.tomlCreates rust-toolchain.toml+nightly
@Append mode (start with it)Appends to existing settingsAppends to existing settings@ --release
!!Reset all configurationsResets all optionsResets all options!!
!featuresReset featuresResets cargo.featuresResets rust-analyzer.cargo.features!features
!targetReset cargo targetDeletes cargo.targetResets rust-analyzer.cargo.target!target
!targetDirReset target directoryDeletes cargo.targetDirResets rust-analyzer.cargo.targetDir!targetDir
!channelReset Rust toolchainRemoves rust-toolchain.tomlRemoves rust-toolchain.toml!channel
!envReset environment variablesResets runnables.extraEnvResets rust-analyzer.runnables.extraEnv!env
!#Reset test binary argsResets runnables.extraTestBinaryArgsResets rust-analyzer.runnables.extraTestBinaryArgs!#
!Reset extra argsResets runnables.extraArgsResets rust-analyzer.runnables.extraArgs!

Override Syntax Examples

--features my-feature,another-feature
--no-default-features --release
DATABASE_URL=postgres://localhost/mydb DEBUG=true
@ --features my-feature

(Append mode - adds to existing settings)

Extension Settings

  • cargoRunner.prioritySymbolKinds: Symbol kinds to prioritize for CodeLens actions
  • cargoRunner.logLevel: Set the logging level for Cargo Runner
  • cargoRunner.cargoHome: Path to Cargo home directory
  • cargoRunner.nextest.enable: Enable cargo-nextest integration

Contributing

We welcome contributions! Please feel free to submit pull requests or open issues on our GitHub repository.

License

This extension is licensed under the MIT License.