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
Formatting via `ruff`'s `--fix` is available since v1.3.0.
7
+
`python-lsp-ruff` is a plugin for `python-lsp-server` that adds linting, code action and formatting capabilities that are provided by [ruff](https://github.com/charliermarsh/ruff),
8
+
a extremely fast Python linter, written in Rust.
9
9
10
10
## Install
11
11
@@ -19,12 +19,29 @@ There also exists an [AUR package](https://aur.archlinux.org/packages/python-lsp
19
19
20
20
# Usage
21
21
22
-
This plugin will disable `flake8`, `pycodestyle`, `pyflakes`, `mccabe` and `isort` by default.
22
+
This plugin will disable `flake8`, `pycodestyle`, `pyflakes`, `mccabe` and `pyls_isort` by default.
23
23
When enabled, all linting diagnostics will be provided by `ruff`.
24
24
Sorting of the imports through `ruff` when formatting is enabled by default.
25
25
The list of code fixes can be changed via the `pylsp.plugins.ruff.format` option.
26
26
27
-
When enabled, sorting of imports when formatting will be provided by `ruff`.
27
+
Any codes given in the `format` option will only be marked as `fixable` for ruff during the formatting operation, the user has to make sure that these codes are also in the list of codes that ruff checks!
28
+
29
+
This example configuration for `neovim` shows how to always sort imports when running `textDocument/formatting`:
30
+
31
+
```lua
32
+
lspconfig.pylsp.setup {
33
+
settings= {
34
+
pylsp= {
35
+
plugins= {
36
+
ruff= {
37
+
enabled=true,
38
+
extendSelect= { "I" },
39
+
},
40
+
}
41
+
}
42
+
}
43
+
}
44
+
```
28
45
29
46
# Configuration
30
47
@@ -48,6 +65,6 @@ the valid configuration keys:
48
65
-`pylsp.plugins.ruff.perFileIgnores`: File-specific error codes to be ignored.
49
66
-`pylsp.plugins.ruff.select`: List of error codes to enable.
50
67
-`pylsp.plugins.ruff.extendSelect`: Same as select, but append to existing error codes.
51
-
-`pylsp.plugins.ruff.format`: List of error codes to fix during formatting.
68
+
-`pylsp.plugins.ruff.format`: List of error codes to fix during formatting. The default is `["I"]`, any additional codes are appended to this list.
52
69
53
70
For more information on the configuration visit [Ruff's homepage](https://beta.ruff.rs/docs/configuration/).
0 commit comments