Skip to content

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+).

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
Terminal window
cargo install cargo-rsx --version 0.13.0 --locked
cargo rsx doctor --manifest-path demo/Cargo.toml

doctor inspects the resolved Cargo dependency graph (aliases, Git dependencies, published snapshots) and can also verify hot-patch readiness:

Terminal window
cargo rsx dev --check --manifest-path tests/fixtures/hot-reload/Cargo.toml --features hotreload,kit
cargo rsx dev my-bin

cargo 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.

Terminal window
cargo rsx lint --deny-warnings
cargo rsx lint --min-severity warning --json
cargo rsx fmt --check
cargo rsx fmt src/main.rs --write
  • Workspace-aware: lint follows workspace members and reads each crate’s rsx.toml and tailwind-scale feature (--tailwind overrides). Use --quiet / -q for errors only; --deny-warnings still fails if warnings are hidden by --min-severity.
  • Non-invasive formatting: fmt rewrites 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 (local macro_rules! shadowing is respected). Incomplete Rust files still expose balanced RSX macros to editor/lint tools while reporting rsx/rust-syntax.
  • Structured codes: JSON and LSP diagnostics include stable codes such as rsx/missing-loop-key, rsx/missing-required-attribute, and rsx/missing-component-prop.
Terminal window
cargo rsx theme check --manifest-path demo/Cargo.toml
cargo rsx theme list --manifest-path demo/Cargo.toml --json
cargo rsx theme explain bg-primary --manifest-path demo/Cargo.toml
printf '<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.

Terminal window
cargo rsx convert component.tsx --tailwind
cargo rsx preview src/main.rs --watch
cargo rsx migrate src/main.rs # dry run
cargo rsx migrate src/main.rs --write # apply once
  • convert: Powered by SWC; preserves simple identifiers/member access and emits review notes for JavaScript expressions, handlers, and unsupported classes. Pass --tailwind to emit rsx_tw! { ... }.
  • preview: Serves an approximate static layout at http://127.0.0.1:9230 (with --watch reloading on both .rs and rsx.toml edits). 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 enabling tailwind-scale or [options] spacing-scale = "tailwind", leaving rsx_tw!, explicit units, and fractions untouched.
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.toml color swatches.
  • Diagnostics with quick fixes (bare text, mismatched closing tags, missing required props, missing loop keys).
  • Live file watching on rsx.toml and Cargo.toml.

For fast local native rebuild loops, see Measure development reloads.