Skip to content

Commit 6539757

Browse files
committed
Add Configuration section to README
Document configuration caching.
1 parent 5a3ec80 commit 6539757

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,31 @@ To avoid unexpected results you should make sure `yapf` and `autopep8` are not i
2121
- The code will only be formatted if it is syntactically valid Python.
2222
- Text selections are treated as if they were a separate Python file.
2323
Unfortunately this means you can't format an indented block of code.
24-
- `python-lsp-black` will use your project's [pyproject.toml](https://github.com/psf/black#pyprojecttoml) if it has one.
25-
- `python-lsp-black` only officially supports the latest stable version of [black](https://github.com/psf/black). An effort is made to keep backwards-compatibility but older black versions will not be actively tested.
24+
- `python-lsp-black` will use your project's
25+
[pyproject.toml](https://github.com/psf/black#pyprojecttoml) if it has one.
26+
- `python-lsp-black` only officially supports the latest stable version of
27+
[black](https://github.com/psf/black). An effort is made to keep backwards-compatibility
28+
but older black versions will not be actively tested.
29+
- The plugin can cache the black configuration that applies to each Python file, this
30+
improves performance of the plugin. When configuration caching is enabled any changes to
31+
black's configuration will need the LSP server to be restarted. Configuration caching
32+
can be disabled with the `cache_config` option, see *Configuration* below.
33+
34+
# Configuration
35+
36+
The plugin follows [python-lsp-server's
37+
configuration](https://github.com/python-lsp/python-lsp-server/#configuration=). These are
38+
the valid configuration keys:
39+
40+
- `pylsp.plugins.black.enabled`: boolean to enable/disable the plugin.
41+
- `pylsp.plugins.black.cache_config`: a boolean to enable black configuration caching (see
42+
*Usage*). `false` by default.
43+
- `pylsp.plugins.black.line_length`: an integer that maps to [black's
44+
`max-line-length`](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length)
45+
setting. Defaults to 88 (same as black's default). This can also be set through black's
46+
configuration files, which should be preferred for multi-user projects.
47+
- `pylsp.plugins.black.preview`: a boolean to enable or disable [black's `--preview`
48+
setting](https://black.readthedocs.io/en/stable/the_black_code_style/future_style.html#preview-style).
2649

2750
# Development
2851

@@ -35,8 +58,8 @@ pip install -e .[dev]
3558
```
3659

3760
This project uses [pre-commit](https://pre-commit.com/) hooks to control code quality,
38-
install them to run them when creating a git commit, thus avoiding seeing errors when you
39-
create a pull request:
61+
install them to run automatically when creating a git commit, thus avoiding seeing errors
62+
when you create a pull request:
4063

4164
```shell
4265
pre-commit install

0 commit comments

Comments
 (0)