Skip to content

Commit d11a03f

Browse files
committed
provide example config, more details
1 parent 09518aa commit d11a03f

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
[![Anaconda](https://anaconda.org/conda-forge/python-lsp-ruff/badges/version.svg)](https://anaconda.org/conda-forge/python-lsp-ruff)
55
[![Python](https://github.com/python-lsp/python-lsp-ruff/actions/workflows/python.yml/badge.svg)](https://github.com/python-lsp/python-lsp-ruff/actions/workflows/python.yml)
66

7-
Linter plugin for pylsp based using ruff.
8-
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.
99

1010
## Install
1111

@@ -19,12 +19,29 @@ There also exists an [AUR package](https://aur.archlinux.org/packages/python-lsp
1919

2020
# Usage
2121

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.
2323
When enabled, all linting diagnostics will be provided by `ruff`.
2424
Sorting of the imports through `ruff` when formatting is enabled by default.
2525
The list of code fixes can be changed via the `pylsp.plugins.ruff.format` option.
2626

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+
```
2845

2946
# Configuration
3047

@@ -48,6 +65,6 @@ the valid configuration keys:
4865
- `pylsp.plugins.ruff.perFileIgnores`: File-specific error codes to be ignored.
4966
- `pylsp.plugins.ruff.select`: List of error codes to enable.
5067
- `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.
5269

5370
For more information on the configuration visit [Ruff's homepage](https://beta.ruff.rs/docs/configuration/).

0 commit comments

Comments
 (0)