You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
7
11
8
12
### Setup
9
13
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.
11
20
12
-
#### Visual Studio Code
21
+
#### VS Code
13
22
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).
15
24
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:
17
27
18
28

19
29
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:
21
39
22
40
```json
23
41
{
24
-
"ruff.nativeServer": true
42
+
"[python]": {
43
+
"editor.formatOnSave": true,
44
+
"editor.defaultFormatter": "charliermarsh.ruff"
45
+
}
25
46
}
26
47
```
27
48
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.
29
54
30
55
#### Neovim
31
56
@@ -35,8 +60,9 @@ See the [Neovim setup guide](docs/setup/NEOVIM.md).
35
60
36
61
See the [Helix setup guide](docs/setup//HELIX.md).
37
62
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
-
40
63
### Contributing
41
64
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.
Copy file name to clipboardExpand all lines: crates/ruff_server/docs/MIGRATION.md
+13-10Lines changed: 13 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,13 @@
1
1
## Migrating From `ruff-lsp`
2
2
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.
4
5
5
6
> \[!NOTE\]
6
7
>
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.
10
11
11
12
### Unsupported Settings
12
13
@@ -20,14 +21,15 @@ Several `ruff-lsp` settings are not supported by `ruff server`. These are, as fo
20
21
-`logLevel`
21
22
-`path`
22
23
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.
25
27
26
28
### New Settings
27
29
28
30
`ruff server` introduces several new settings that `ruff-lsp` does not have. These are, as follows:
29
31
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.
31
33
-`configurationPreference`: Used to specify how you want to resolve server settings with local file configuration. The following values are available:
32
34
-`"editorFirst"`: The default strategy - configuration set in the server settings takes priority over configuration set in `.toml` files.
33
35
-`"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
40
42
-`lint.ignore`: Sets rule codes to disable. See [the documentation](https://docs.astral.sh/ruff/settings/#lint_ignore) for more details.
41
43
-`lint.preview`: Enables [preview mode](https://docs.astral.sh/ruff/settings/#lint_preview) for the linter; enables unstable rules and fixes.
42
44
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>"]`.
45
48
46
49
### Examples
47
50
@@ -53,7 +56,7 @@ Let's say you have these settings in VS Code:
53
56
}
54
57
```
55
58
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:
0 commit comments