RA Assist
A VS Code extension for toggling rust-analyzer between Host (x86_64) and MU (RISC-V accelerator) targets.
Features
- Toggle rust-analyzer target via status bar button, keyboard shortcut, or command palette
- Automatic RUSTFLAGS configuration (
--cfg=host / --cfg=mu)
cargo.cfgs with ! prefix to gray out inactive cfg blocks in the editor
- Configurable directory exclusions per mode
- Status bar indicator showing current mode
- Auto-fallback to Host mode if MU target file is missing
- QEMU CodeLens: "Run QEMU" button above
fn main() and #[test] functions
- Automatic TOML formatter setup — configures
even-better-toml with system taplo when taplo.toml exists
Installation
VS Code Marketplace
Search for "RA Assist" in the Extensions view (Ctrl+Shift+X), or run:
ext install eshonar.ra-assist
Install from VSIX
Download the .vsix file from GitHub Releases, then:
code --install-extension ra-assist-*.vsix
Usage
Toggle Target
| Method |
Action |
| Status bar |
Click on Host or MU indicator |
| Keyboard |
Ctrl+Alt+T (Windows/Linux) or Cmd+Alt+T (Mac) |
| Command palette |
Ctrl+Shift+P then RA Assist: Toggle Target |
Mode Behavior
| Mode |
RUSTFLAGS |
rust-analyzer target |
| Host |
--cfg=host |
Default (native) |
| MU |
--cfg=mu |
Custom RISC-V target JSON |
QEMU CodeLens
The extension adds a "Run QEMU" CodeLens above fn main() and #[test] functions. Clicking it runs the binary/test through QEMU via the configured runner script.
fn main() → cargo run --package <name> with QEMU runner
#[test] → cargo test --package <name> -- <test> --exact --nocapture with QEMU runner
The runner is set via a configurable environment variable (default: CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER), overriding .cargo/config.toml.
Configuration
Add to your .vscode/settings.json:
{
"ra-assist.targetTriplePath": "xcena",
"ra-assist.targetTriple": "riscv64imfdxmetis-unknown-none-elf.json",
"ra-assist.muExcludeDirs": ["mu-builder"],
"ra-assist.hostExcludeDirs": []
}
Settings
| Setting |
Type |
Default |
Description |
targetTriplePath |
string |
"xcena" |
Directory containing the target JSON (relative to workspace or absolute) |
targetTriple |
string |
"riscv64imfdxmetis-unknown-none-elf.json" |
Target triple JSON filename |
excludeDirs |
array |
[] |
Directories to exclude from rust-analyzer in all modes |
muExcludeDirs |
array |
["mu-builder"] |
Directories to exclude in MU mode |
hostExcludeDirs |
array |
[] |
Directories to exclude in Host mode |
qemuCodeLensEnabled |
boolean |
true |
Enable QEMU CodeLens above fn main() and #[test] |
qemuRunner |
string |
"./dev/run.sh --qemu" |
Runner command for QEMU execution |
qemuRunnerEnvVar |
string |
"CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER" |
Environment variable for the cargo runner |
qemuRunnerSearchPaths |
array |
["dev/run.sh", "mjol/dev/run.sh"] |
Paths to search for the runner script (walked upward) |
qemuTestArgs |
array |
[] |
Additional cargo test arguments (e.g., ["--release"]) |
qemuTestEnv |
object |
{} |
Extra environment variables for QEMU execution |
How It Works
When toggling modes, the extension:
- Updates
rust-analyzer.cargo.extraEnv.RUSTFLAGS with the appropriate --cfg flag
- Updates
rust-analyzer.runnables.extraEnv.RUSTFLAGS for Run/Debug buttons
- Sets
rust-analyzer.cargo.cfgs with ! prefix to gray out inactive cfg blocks (e.g., ["mu", "!host"])
- Sets/removes
rust-analyzer.cargo.target to the MU target JSON path
- Configures
rust-analyzer.cargo.extraArgs for build-std (MU mode only)
- Updates
rust-analyzer.files.excludeDirs based on mode-specific exclusion lists
- Restarts rust-analyzer to apply changes
- If
taplo.toml exists, configures TOML formatter (even-better-toml) to use system taplo binary
Requirements
- VS Code 1.75.0 or higher
- rust-analyzer extension
- For MU mode: valid target triple JSON file in the configured path
License
Apache-2.0