CLI & Editors
cargo-rsx and the editor language server (cargo rsx lsp) share the macro’s exact Rust parser, class catalog, and rsx.toml configuration. Install the CLI with Rust 1.98+ (the gpui-rsx macro/core library supports Rust 1.88+).
Quick Command Reference
Section titled “Quick Command Reference”| Command | Purpose |
|---|---|
cargo rsx doctor |
Verify GPUI dependency graph, aliases, and hot-reload readiness |
cargo rsx dev |
Run hot-reload preflight and launch dx serve --hot-patch |
cargo rsx lint |
Check RSX macros across a workspace (--deny-warnings, --json) |
cargo rsx fmt |
Format RSX macro bodies without touching surrounding Rust (--check, --write) |
cargo rsx theme check/list/explain |
Validate rsx.toml tokens and inspect generated GPUI calls |
cargo rsx expand |
Print the generated Rust expansion for a standalone RSX body |
cargo rsx convert |
Convert JSX / TSX files into RSX plus manual review notes |
cargo rsx preview |
Serve a local live static layout preview at http://127.0.0.1:9230 |
cargo rsx migrate |
Divide numeric spacing classes by 4 when adopting Tailwind scale |
cargo rsx lsp |
Language server powering VS Code and Zed integrations |
1. Install & Diagnose
Section titled “1. Install & Diagnose”cargo install cargo-rsx --version 0.13.0 --lockedcargo rsx doctor --manifest-path demo/Cargo.tomldoctor inspects the resolved Cargo dependency graph (aliases, Git dependencies, published snapshots) and can also verify hot-patch readiness:
cargo rsx dev --check --manifest-path tests/fixtures/hot-reload/Cargo.toml --features hotreload,kitcargo rsx dev my-bincargo rsx dev auto-detects hotreload / hot-reload features when --features is omitted, checks dx serve --hot-patch support (override the binary via RSX_DX), and warns if macros named rsx might be intercepted by Dioxus CLI. See hot-reload troubleshooting for details.
2. Lint & Format in CI
Section titled “2. Lint & Format in CI”cargo rsx lint --deny-warningscargo rsx lint --min-severity warning --jsoncargo rsx fmt --checkcargo rsx fmt src/main.rs --write- Workspace-aware:
lintfollows workspace members and reads each crate’srsx.tomlandtailwind-scalefeature (--tailwindoverrides). Use--quiet/-qfor errors only;--deny-warningsstill fails if warnings are hidden by--min-severity. - Non-invasive formatting:
fmtrewrites balanced RSX macro bodies only and leaves surrounding Rust—and macro bodies containing comments—untouched. - Import aliases & recovery: Direct macro aliases like
use gpui_rsx::{rsx as gpui_view, rsx_tw as tw};preserve strictness and spacing scale in block scope (localmacro_rules!shadowing is respected). Incomplete Rust files still expose balanced RSX macros to editor/lint tools while reportingrsx/rust-syntax. - Structured codes: JSON and LSP diagnostics include stable codes such as
rsx/missing-loop-key,rsx/missing-required-attribute, andrsx/missing-component-prop.
3. Inspect Themes & Expansions
Section titled “3. Inspect Themes & Expansions”cargo rsx theme check --manifest-path demo/Cargo.tomlcargo rsx theme list --manifest-path demo/Cargo.toml --jsoncargo rsx theme explain bg-primary --manifest-path demo/Cargo.tomlprintf '<div class="flex gap-4" />' | cargo rsx expand -expand prints the full Rust output (including inline dynamic helpers when shared runtime is disabled) and accepts --strict or --tailwind. For files containing multiple macros, use preview --index N or the editor’s hover expansion.
4. Convert JSX, Preview & Migrate Spacing
Section titled “4. Convert JSX, Preview & Migrate Spacing”cargo rsx convert component.tsx --tailwindcargo rsx preview src/main.rs --watchcargo rsx migrate src/main.rs # dry runcargo rsx migrate src/main.rs --write # apply onceconvert: Powered by SWC; preserves simple identifiers/member access and emits review notes for JavaScript expressions, handlers, and unsupported classes. Pass--tailwindto emitrsx_tw! { ... }.preview: Serves an approximate static layout athttp://127.0.0.1:9230(with--watchreloading on both.rsandrsx.tomledits). Like the Playground, preview does not execute arbitrary Rust expressions or type-check—verify interactions in a native GPUI build.migrate: Divides numeric spacing classes by 4 once before enablingtailwind-scaleor[options] spacing-scale = "tailwind", leavingrsx_tw!, explicit units, and fractions untouched.
5. Connect Your Editor
Section titled “5. Connect Your Editor”| Editor | Setup |
|---|---|
| VS Code | Download the .vsix from the 0.13.0 release and run Extensions: Install from VSIX. |
| Zed | Install editors/zed from this repository as a development extension. If you customize Rust language servers, add "gpui-rsx" alongside "rust-analyzer". |
Both extensions run cargo rsx lsp alongside rust-analyzer and provide:
- Static class, tag, GPUI method, and local
#[component]prop completions. - Expansion hover previews, semantic highlighting, and
rsx.tomlcolor swatches. - Diagnostics with quick fixes (bare text, mismatched closing tags, missing required props, missing loop keys).
- Live file watching on
rsx.tomlandCargo.toml.
For fast local native rebuild loops, see Measure development reloads.