mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Add rome_formatter
fork as ruff_formatter
(#2872)
The Ruff autoformatter is going to be based on an intermediate representation (IR) formatted via [Wadler's algorithm](https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf). This is architecturally similar to [Rome](https://github.com/rome/tools), Prettier, [Skip](https://github.com/skiplang/skip/blob/master/src/tools/printer/printer.sk), and others. This PR adds a fork of the `rome_formatter` crate from [Rome](https://github.com/rome/tools), renamed here to `ruff_formatter`, which provides generic definitions for a formatter IR as well as a generic IR printer. (We've also pulled in `rome_rowan`, `rome_text_size`, and `rome_text_edit`, though some of these will be removed in future PRs.) Why fork? `rome_formatter` contains code that's specific to Rome's AST representation (e.g., it relies on a fork of rust-analyzer's `rowan`), and we'll likely want to support different abstractions and formatting capabilities (there are already a few changes coming in future PRs). Once we've dropped `ruff_rowan` and trimmed down `ruff_formatter` to the code we currently need, it's also not a huge surface area to maintain and update.
This commit is contained in:
parent
ac028cd9f8
commit
3ef1c2e303
83 changed files with 27547 additions and 1 deletions
21
crates/ruff_formatter/src/prelude.rs
Normal file
21
crates/ruff_formatter/src/prelude.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
pub use crate::builders::*;
|
||||
pub use crate::format_element::*;
|
||||
pub use crate::format_extensions::{MemoizeFormat, Memoized};
|
||||
pub use crate::formatter::Formatter;
|
||||
pub use crate::printer::PrinterOptions;
|
||||
pub use crate::trivia::{
|
||||
format_dangling_comments, format_leading_comments, format_only_if_breaks, format_removed,
|
||||
format_replaced, format_trailing_comments, format_trimmed_token,
|
||||
};
|
||||
|
||||
pub use crate::diagnostics::FormatError;
|
||||
pub use crate::format_element::document::Document;
|
||||
pub use crate::format_element::tag::{LabelId, Tag, TagKind};
|
||||
pub use crate::verbatim::{
|
||||
format_bogus_node, format_or_verbatim, format_suppressed_node, format_verbatim_node,
|
||||
};
|
||||
|
||||
pub use crate::{
|
||||
best_fitting, dbg_write, format, format_args, write, Buffer as _, BufferExtensions, Format,
|
||||
Format as _, FormatResult, FormatRule, FormatWithRule as _, SimpleFormatContext,
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue