Air is an R language server and formatter written in Rust. Workspace crate layout under crates/ with a CLI binary in crates/air/.
- Rust edition and version are reported in workspace level
Cargo.toml - Uses
biome_formatterfor the formatting engine andignorecrate for file walking - Config file:
air.tomldiscovered by walking up directory ancestors - Snapshot testing with
insta
- One item per
useline, no{}grouping - Grouped in order:
std, external crates,crate/super, with groups separated by blank lines
thiserror::Errorfor structured error enums; manualDisplayimpls when messages need custom formatting (e.g. path underlining)- CLI-facing errors: log with
tracing::error!and returnOk(ExitStatus::Error). Reserveanyhow::Errorfor truly unexpected errors. tracing::trace!for file inclusion/exclusion decisions
- Normalize paths with
fs::normalize_pathat function boundaries - Prefer returning structured enums (e.g.
FormattedSource::Changed/Unchanged) over booleans
- Explain the "why", not the "what"
- Reference GitHub issues when behavior is motivated by a specific bug report
- Use
just testto run tests via nextest, NOTcargo test - Example:
just test -p workspace --lib discovery::test - Passes arguments through to
cargo nextest run
#[cfg(test)] mod testat the bottom of the source file- Use
tempfile::TempDir, immediately shadow:let tempdir = TempDir::new()?; let tempdir = tempdir.path(); - Use
anyhow::Result<()>as test return type - Write files into temp dirs to set up test fixtures inline
- Live in
crates/air/tests/integration/ insta::assert_snapshot!for CLI output assertions- Build
Commandwith method chaining:.current_dir(),.arg(),.run()or.run_with_stdin() .remove_arguments()when snapshot would contain machine-specific absolute paths.normalize_os_path_separator()for cross-platform path assertions- Test both the happy path and the exclusion/rejection path