ruff/crates/ruff_python_formatter/src
Zanie Blue 9cdac2d6fb
Add support for using uv as an alternative formatter backend (#19665)
This adds a new `backend: internal | uv` option to the LSP
`FormatOptions` allowing users to perform document and range formatting
operations though uv. The idea here is to prototype a solution for users
to transition to a `uv format` command without encountering version
mismatches (and consequently, formatting differences) between the LSP's
version of `ruff` and uv's version of `ruff`.

The primarily alternative to this would be to use uv to discover the
`ruff` version used to start the LSP in the first place. However, this
would increase the scope of a minimal `uv format` command beyond "run a
formatter", and raise larger questions about how uv should be used to
coordinate toolchain discovery. I think those are good things to
explore, but I'm hesitant to let them block a `uv format`
implementation. Another downside of using uv to discover `ruff`, is that
it needs to be implemented _outside_ the LSP; e.g., we'd need to change
the instructions on how to run the LSP and implement it in each editor
integration, like the VS Code plugin.

---------

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2025-09-09 20:39:53 +05:30
..
comments [ty] Shrink size of AstNodeRef (#20028) 2025-08-22 17:03:22 -04:00
expression Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
module [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
other Disallow newlines in format specifiers of single quoted f- or t-strings (#18708) 2025-06-18 14:56:15 +02:00
pattern Update pre-commit dependencies (#19162) 2025-07-07 04:07:44 +00:00
snapshots Update insta snapshots (#14366) 2024-11-15 19:31:15 +01:00
statement [formatter] Fix missing blank lines before decorated classes in .pyi files (#18888) 2025-06-24 16:25:44 +02:00
string Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
type_param [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
builders.rs Implement template strings (#17851) 2025-05-30 15:00:56 -05:00
cli.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
context.rs Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
db.rs Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
generated.rs Implement template strings (#17851) 2025-05-30 15:00:56 -05:00
lib.rs Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
main.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
options.rs Add support for using uv as an alternative formatter backend (#19665) 2025-09-09 20:39:53 +05:30
prelude.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
preview.rs [formatter] Fix missing blank lines before decorated classes in .pyi files (#18888) 2025-06-24 16:25:44 +02:00
range.rs [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
shared_traits.rs Upgrade Rust toolchain to 1.83 (#14677) 2024-11-29 12:05:05 +00:00
verbatim.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00