mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-27 10:26:26 +00:00
Update setup instructions for Zed 0.208.0+ (#20902)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
cb98933c50
commit
fe4e3e2e75
1 changed files with 44 additions and 67 deletions
|
|
@ -464,59 +464,46 @@ under the [`lsp.ruff.initialization_options.settings`](https://zed.dev/docs/conf
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
!!! note
|
|
||||||
|
|
||||||
Support for multiple formatters for a given language is only available in Zed version
|
|
||||||
`0.146.0` and later.
|
|
||||||
|
|
||||||
You can configure Ruff to format Python code on-save by registering the Ruff formatter
|
You can configure Ruff to format Python code on-save by registering the Ruff formatter
|
||||||
and enabling the [`format_on_save`](https://zed.dev/docs/configuring-zed#format-on-save) setting:
|
and enabling the [`format_on_save`](https://zed.dev/docs/configuring-zed#format-on-save) setting:
|
||||||
|
|
||||||
=== "Zed 0.146.0+"
|
```json
|
||||||
|
{
|
||||||
```json
|
"languages": {
|
||||||
{
|
"Python": {
|
||||||
"languages": {
|
"language_servers": ["ruff"],
|
||||||
"Python": {
|
"format_on_save": "on",
|
||||||
"language_servers": ["ruff"],
|
"formatter": [
|
||||||
"format_on_save": "on",
|
{
|
||||||
"formatter": [
|
"language_server": {
|
||||||
{
|
"name": "ruff"
|
||||||
"language_server": {
|
}
|
||||||
"name": "ruff"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
```
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
You can configure Ruff to fix lint violations and/or organize imports on-save by enabling the
|
You can configure Ruff to fix lint violations and/or organize imports on-save by enabling the
|
||||||
`source.fixAll.ruff` and `source.organizeImports.ruff` code actions respectively:
|
`source.fixAll.ruff` and `source.organizeImports.ruff` code actions respectively:
|
||||||
|
|
||||||
=== "Zed 0.146.0+"
|
```json
|
||||||
|
{
|
||||||
```json
|
"languages": {
|
||||||
{
|
"Python": {
|
||||||
"languages": {
|
"language_servers": ["ruff"],
|
||||||
"Python": {
|
"format_on_save": "on",
|
||||||
"language_servers": ["ruff"],
|
"formatter": [
|
||||||
"format_on_save": "on",
|
// Fix all auto-fixable lint violations
|
||||||
"formatter": [
|
{ "code_action": "source.fixAll.ruff" },
|
||||||
{
|
// Organize imports
|
||||||
"code_actions": {
|
{ "code_action": "source.organizeImports.ruff" }
|
||||||
// Fix all auto-fixable lint violations
|
]
|
||||||
"source.fixAll.ruff": true,
|
|
||||||
// Organize imports
|
|
||||||
"source.organizeImports.ruff": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Taken together, you can configure Ruff to format, fix, and organize imports on-save via the
|
Taken together, you can configure Ruff to format, fix, and organize imports on-save via the
|
||||||
following `settings.json`:
|
following `settings.json`:
|
||||||
|
|
@ -528,28 +515,18 @@ following `settings.json`:
|
||||||
ensure that the formatter takes care of any remaining style issues after the code actions have
|
ensure that the formatter takes care of any remaining style issues after the code actions have
|
||||||
been applied.
|
been applied.
|
||||||
|
|
||||||
=== "Zed 0.146.0+"
|
```json
|
||||||
|
{
|
||||||
```json
|
"languages": {
|
||||||
{
|
"Python": {
|
||||||
"languages": {
|
"language_servers": ["ruff"],
|
||||||
"Python": {
|
"format_on_save": "on",
|
||||||
"language_servers": ["ruff"],
|
"formatter": [
|
||||||
"format_on_save": "on",
|
{ "code_action": "source.fixAll.ruff" },
|
||||||
"formatter": [
|
{ "code_action": "source.organizeImports.ruff" },
|
||||||
{
|
{ "language_server": { "name": "ruff" } }
|
||||||
"code_actions": {
|
]
|
||||||
"source.organizeImports.ruff": true,
|
|
||||||
"source.fixAll.ruff": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"language_server": {
|
|
||||||
"name": "ruff"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue