Skip to content

Commit 35a7251

Browse files
committed
doc: text editor/IDE configuration
Add the guidance on how to configure the text editor/IDE to get direct style/linter/type checker feedback while coding. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent ade3c74 commit 35a7251

File tree

1 file changed

+72
-1
lines changed

1 file changed

+72
-1
lines changed

README.md

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,78 @@ ruff check lib/ tests/
366366
flake8
367367
```
368368

369-
The code checker diagnostics can also be shown directly in your IDE or text editor.
369+
The code checker diagnostics can also be shown directly in your IDE or text editor, by using plugins or language
370+
servers (LSP).
371+
372+
### Visual Studio Code
373+
374+
A few plugins are recommended to properly report the diagnostics during the development:
375+
* [BasedPyright](https://marketplace.visualstudio.com/items?itemName=detachhead.basedpyright)
376+
* [cornflakes-linter](https://marketplace.visualstudio.com/items?itemName=kevinglasson.cornflakes-linter)
377+
* [ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff)
378+
379+
If you want the coding style warning to appear as you type, set the option
380+
`Extensions` > `cornflakes-linter` > `Cornflakes > linter: Run` to `onType`.
381+
382+
~~~json
383+
{
384+
"cornflakes.linter.run": "onType"
385+
}
386+
~~~
387+
388+
### Helix
389+
390+
Install the required language servers:
391+
* basedpyright with `uv tool install basedpyright`
392+
* pylsp with `uv tool install python-lsp-server[flake8] --with pylsp-rope`.
393+
394+
`ruff`, which is also used as a language server, is already installed as a dev dependency.
395+
396+
Create a `.helix/language.toml` in the project. Make sure to exclude it in git,
397+
either in your user configuration (`~/.config/git/ignore`) or in the project
398+
configuration (`.git/info/exclude`).
399+
400+
~~~toml
401+
[[language]]
402+
name = "python"
403+
language-servers = [
404+
"basedpyright",
405+
"pylsp",
406+
"ruff",
407+
]
408+
auto-format = false
409+
410+
[language-server.basedpyright.config.basedpyright.analysis]
411+
diagnosticMode = "workspace"
412+
413+
[language-server.pylsp.config.pylsp.plugins]
414+
autopep8.enabled = false
415+
flake8.enabled = true
416+
jedi.enabled = false
417+
mccabe.enabled = false
418+
preload.enabled = false
419+
pycodestyle.enabled = false
420+
pydocstyle.enabled = false
421+
pyflakes.enabled = false
422+
pylint.enabled = false
423+
yapf.enabled = false
424+
~~~
425+
426+
### Other LSP-Compatible Editors
427+
428+
Most modern editors use the Language Server Protocol (LSP) to enhance
429+
functionality. The following servers are generally suggested for this project:
430+
431+
* basedpyright: Real-time type checking ('uv tool install basedpyright').
432+
* pylsp: Coding style feedback via flake8 (`uv tool install "python-lsp-server[flake8]"`).
433+
* ruff: Immediate linting (included as a dev dependency).
434+
435+
Configuration is highly editor-specific; please consult your editor's
436+
documentation. Contributions to these docs via PR are always welcome!
437+
438+
### Others
439+
440+
Please add your configuration hints here!
370441

371442
## VM setup
372443
Many tests expect VMs with:

0 commit comments

Comments
 (0)