Add pyright workspace configuration (#14265)
Release Notes: - Added support for pyright workspace configuration, as described in https://microsoft.github.io/pyright/#/settings .
This commit is contained in:
parent
3deb000f70
commit
21c5ce2bbd
2 changed files with 72 additions and 3 deletions
|
@ -11,6 +11,35 @@ The [pyright](https://github.com/microsoft/pyright) language server offers flexi
|
|||
|
||||
For more information, see the Pyright [configuration documentation](https://microsoft.github.io/pyright/#/configuration).
|
||||
|
||||
### Settings
|
||||
|
||||
The [pyright](https://github.com/microsoft/pyright) language server also accepts specific LSP related settings, not necessarily connected to a project. These can be changed in the `lsp` section of your `settings.json`.
|
||||
|
||||
For example, in order to:
|
||||
- use strict type-checking level
|
||||
- diagnose all files in the workspace instead of the only open files default
|
||||
- provide the path to a specific python interpreter
|
||||
|
||||
```json
|
||||
{
|
||||
"lsp": {
|
||||
"pyright": {
|
||||
"settings": {
|
||||
"python.analysis": {
|
||||
"diagnosticMode": "workspace",
|
||||
"typeCheckingMode": "strict"
|
||||
},
|
||||
"python": {
|
||||
"pythonPath": ".venv/bin/python"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For more information, see the Pyright [settings documentation](https://microsoft.github.io/pyright/#/settings).
|
||||
|
||||
### Virtual environments
|
||||
|
||||
A python [virtual environment](https://docs.python.org/3/tutorial/venv.html) allows you to store all of a project's dependencies, including the Python interpreter and package manager, in a single directory that's isolated from any other Python projects on your computer.
|
||||
|
@ -48,6 +77,22 @@ venvPath = "."
|
|||
venv = ".venv"
|
||||
```
|
||||
|
||||
You can also configure this option directly in your `settings.json` file ([pyrights settings](#settings)), as recommended in [Configuring Your Python Environment](https://microsoft.github.io/pyright/#/import-resolution?id=configuring-your-python-environment).
|
||||
|
||||
```json
|
||||
{
|
||||
"lsp": {
|
||||
"pyright": {
|
||||
"settings": {
|
||||
"python": {
|
||||
"pythonPath": ".venv/bin/python"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Code formatting
|
||||
|
||||
The Pyright language server does not provide code formatting. If you want to automatically reformat your Python code when saving, you'll need to specify an \_external_code formatter in your settings. See the [configuration](../configuring-zed.md) documentation for more information.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue