Skip to content

Commit 3c22a3b

Browse files
Minor edits to ruff server docs (#11500)
## Summary Minor copy edits based on my read-through. Feel free to disagree anywhere.
1 parent 6263923 commit 3c22a3b

File tree

2 files changed

+53
-24
lines changed

2 files changed

+53
-24
lines changed

crates/ruff_server/README.md

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,56 @@
11
## The Ruff Language Server
22

3-
Welcome! `ruff server` is a language server that powers editor integrations with Ruff. The job of the language server is to
4-
listen for requests from the client, (in this case, the code editor of your choice) and call into Ruff's linter and formatter
5-
crates to create real-time diagnostics or formatted code, which is then sent back to the client. It also tracks configuration
6-
files in your editor's workspace, and will refresh its in-memory configuration whenever those files are modified.
3+
Welcome!
4+
5+
`ruff server` is a language server that powers Ruff's editor integrations.
6+
7+
The job of the language server is to listen for requests from the client (in this case, the code editor of your choice)
8+
and call into Ruff's linter and formatter crates to construct real-time diagnostics or formatted code, which is then
9+
sent back to the client. It also tracks configuration files in your editor's workspace, and will refresh its in-memory
10+
configuration whenever those files are modified.
711

812
### Setup
913

10-
We have specific setup instructions depending on your editor. If you don't see your editor on this list and would like a setup guide, please open an issue.
14+
We have specific setup instructions depending on your editor. If you don't see your editor on this list and would like a
15+
setup guide, please open an issue.
16+
17+
If you're transferring your configuration from [`ruff-lsp`](https://github.com/astral-sh/ruff-lsp), regardless of
18+
editor, there are several settings which have changed or are no longer available. See the [migration guide](docs/MIGRATION.md) for
19+
more.
1120

12-
#### Visual Studio Code
21+
#### VS Code
1322

14-
Install the [Ruff extension from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff).
23+
Install the Ruff extension from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff).
1524

16-
As this server is still in beta, you will need to enable the `Native Server` extension setting:
25+
As this server is still in Beta, you will need to enable the "Native Server" extension setting, either in the settings
26+
UI:
1727

1828
![A screenshot showing an enabled "Native Server" extension setting in the VS Code settings view](assets/nativeServer.png)
1929

20-
You can also set it in your user / workspace JSON settings as follows:
30+
Or in your `settings.json`:
31+
32+
```json
33+
{
34+
"ruff.nativeServer": true
35+
}
36+
```
37+
38+
From there, you can configure Ruff to format Python code on-save with:
2139

2240
```json
2341
{
24-
"ruff.nativeServer": true
42+
"[python]": {
43+
"editor.formatOnSave": true,
44+
"editor.defaultFormatter": "charliermarsh.ruff"
45+
}
2546
}
2647
```
2748

28-
The language server used by the extension will be, by default, the one in your actively-installed `ruff` binary. If you don't have `ruff` installed and haven't provided a path to the extension, it comes with a bundled `ruff` version that it will use instead.
49+
For more, see [_Configuring VS Code_](https://github.com/astral-sh/ruff-vscode?tab=readme-ov-file#configuring-vs-code)
50+
in the Ruff extension documentation.
51+
52+
By default, the extension will run against the `ruff` binary that it discovers in your environment. If you don't have
53+
`ruff` installed, the extension will fall back to a bundled version of the binary.
2954

3055
#### Neovim
3156

@@ -35,8 +60,9 @@ See the [Neovim setup guide](docs/setup/NEOVIM.md).
3560

3661
See the [Helix setup guide](docs/setup//HELIX.md).
3762

38-
If you are transferring your configuration from `ruff-lsp`, regardless of editor, there are several settings which have changed or are no longer available which you should be aware of. See the [migration guide](docs/MIGRATION.md) for more details.
39-
4063
### Contributing
4164

42-
If you're interested in contributing to `ruff server` - well, first of all, thank you! Second of all, you might find the [**contribution guide**](CONTRIBUTING.md) to be a useful resource. Finally, don't hesitate to reach out on our [**Discord**](https://discord.com/invite/astral-sh) if you have questions.
65+
If you're interested in contributing to `ruff server` - well, first of all, thank you! Second of all, you might find the
66+
[**contribution guide**](CONTRIBUTING.md) to be a useful resource.
67+
68+
Finally, don't hesitate to reach out on [**Discord**](https://discord.com/invite/astral-sh) if you have questions.

crates/ruff_server/docs/MIGRATION.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
## Migrating From `ruff-lsp`
22

3-
`ruff server`'s configuration is significantly different from `ruff-lsp`, and as such you may need to update your existing configuration.
3+
While `ruff server` supports the same feature set as [`ruff-lsp`](https://github.com/astral-sh/ruff-lsp), migrating to
4+
`ruff server` may require changes to your Ruff or language server configuration.
45

56
> \[!NOTE\]
67
>
7-
> The VS Code extension settings have documentation that will tell you whether `ruff server` supports a given setting.
8-
> This migration guide may be more useful for the editors that do not have explicitly documented settings for the language server,
9-
> such as Helix or Neovim.
8+
> The [VS Code extension](https://github.com/astral-sh/ruff-vscode) settings include documentation to indicate which
9+
> settings are supported by `ruff server`. As such, this migration guide is primarily targeted at editors that lack
10+
> explicit documentation for `ruff server` settings, such as Helix or Neovim.
1011
1112
### Unsupported Settings
1213

@@ -20,14 +21,15 @@ Several `ruff-lsp` settings are not supported by `ruff server`. These are, as fo
2021
- `logLevel`
2122
- `path`
2223

23-
Note that some of these settings, like `interpreter` and `path`, are still accepted by the VS Code extension. `path`, in particular, can be used to set the ruff binary
24-
used to run `ruff server`. But the server itself will no longer accept these as settings.
24+
Note that some of these settings, like `interpreter` and `path`, are still accepted by the VS Code extension. `path`,
25+
in particular, can be used to specify a dedicated binary to use when initializing `ruff server`. But the language server
26+
itself will no longer accept such settings.
2527

2628
### New Settings
2729

2830
`ruff server` introduces several new settings that `ruff-lsp` does not have. These are, as follows:
2931

30-
- `configuration`: This is a path to a `ruff.toml` or `pyproject.toml` file to use for configuration. By default, Ruff will discover configuration for each project from the filesystem, mirroring the behavior of the Ruff CLI.
32+
- `configuration`: A path to a `ruff.toml` or `pyproject.toml` file to use for configuration. By default, Ruff will discover configuration for each project from the filesystem, mirroring the behavior of the Ruff CLI.
3133
- `configurationPreference`: Used to specify how you want to resolve server settings with local file configuration. The following values are available:
3234
- `"editorFirst"`: The default strategy - configuration set in the server settings takes priority over configuration set in `.toml` files.
3335
- `"filesystemFirst"`: An alternative strategy - configuration set in `.toml` files takes priority over configuration set in the server settings.
@@ -40,8 +42,9 @@ used to run `ruff server`. But the server itself will no longer accept these as
4042
- `lint.ignore`: Sets rule codes to disable. See [the documentation](https://docs.astral.sh/ruff/settings/#lint_ignore) for more details.
4143
- `lint.preview`: Enables [preview mode](https://docs.astral.sh/ruff/settings/#lint_preview) for the linter; enables unstable rules and fixes.
4244

43-
Several of these new settings are replacements for the now-unsupported `format.args` and `lint.args`. For example, if you have been passing in `--select=<RULES>`
44-
to `lint.args`, you can migrate to the new server by using `lint.select` with a value of `["<RULES>"]`.
45+
Several of these new settings are replacements for the now-unsupported `format.args` and `lint.args`. For example, if
46+
you've been passing `--select=<RULES>` to `lint.args`, you can migrate to the new server by using `lint.select` with a
47+
value of `["<RULES>"]`.
4548

4649
### Examples
4750

@@ -53,7 +56,7 @@ Let's say you have these settings in VS Code:
5356
}
5457
```
5558

56-
These can be migrated to the new language server like so:
59+
After enabling the native server, you can migrate your settings like so:
5760

5861
```json
5962
{

0 commit comments

Comments
 (0)