chloro

Crates.iochloro
lib.rschloro
version0.7.5
created_at2025-11-21 01:07:07.159241+00
updated_at2025-12-05 21:52:59.319912+00
descriptionA minimal Rust code formatter
homepagehttps://github.com/lmmx/chloro
repositoryhttps://github.com/lmmx/chloro
max_upload_size
id1942874
size47,741
Louis Maddox (lmmx)

documentation

https://docs.rs/chloro

README

chloro

crates.io documentation MIT/Apache-2.0 licensed pre-commit.ci status free of syn Dependencies: 32 Binary Size: 1.7M

chloro is a minimal Rust code formatter.

Motivation

For when you want to format two source files in a consistent way, as fast as possible.

How it works

Using rowan from the rust-analyzer project, which can give both green and red trees. The latter are notoriously expensive, but a formatter should only need the former.

Proof of concept library/CLI to explore a fast and low memory code formatter [WIP], with use cases of code diffing in mind.

Rustfmt Conformance

Diff 'leaderboard' for how well formatting with chloro matches rustfmt, as tested on rust-analyzer's crates:

Summary: +84,596 / -12,699

Top 5 Removed Lines Top 5 Added Lines
- ) × 219
- r#" × 140
- }, × 108
- check( × 90
- ); × 87
+ }, × 131
+"#) × 104
+ check(r#" × 79
+ } × 68
+ } × 64

Top 20 Most Impacted Files

Rank Size Rank Diff Rank Impact + - File
1 1 23 1.4% 161 11,163 ide/src_hover_tests
2 2 14 3.1% 199 6,520 hir/src_lib
3 3 11 3.5% 217 6,119 ide_assists/src_handlers_extract_function
4 7 5 8.7% 335 3,870 ide/src_goto_definition
5 15 3 12.1% 368 3,029 rust_analyzer/src_lsp_to_proto
6 56 1 46.3% 715 1,544 hir_expand/src_builtin_derive_macro
7 29 4 14.5% 341 2,356 hir_ty/src_next_solver_interner
8 96 2 40.9% 460 1,125 ide/src_navigation_target
9 5 42 3.0% 126 4,153 rust_analyzer/src_config
10 8 39 3.4% 129 3,799 ide/src_rename
11 26 15 7.6% 188 2,459 ide/src_highlight_related
12 10 41 3.6% 127 3,515 hir_def/src_expr_store_lower
13 32 19 8.0% 178 2,223 ide_assists/src_handlers_add_missing_match_arms
14 13 50 3.6% 113 3,116 ide_assists/src_handlers_generate_function
15 11 61 3.1% 101 3,269 ide_completion/src_render
16 114 6 25.6% 259 1,010 hir_def/src_expr_store
17 37 21 8.2% 168 2,052 ide_assists/src_handlers_destructure_tuple_binding
18 4 196 0.8% 42 5,039 hir_ty/src_tests_traits
19 62 13 13.5% 200 1,485 hir_def/src_lib
20 52 16 11.2% 183 1,641 ide/src_typing

Installation

Add chloro to your Cargo.toml:

[dependencies]
chloro = "0.7"

CLI Installation

  • pre-built binary: cargo binstall chloro (requires cargo-binstall),
  • build from source: cargo install chloro --features cli

License

This project is licensed under either of:

at your option.

Commit count: 0

cargo fmt