Docs Party 2024 (#15876)
Co-authored-by: Raunak Raj <nkray21111983@gmail.com> Co-authored-by: Thorsten Ball <mrnugget@gmail.com> Co-authored-by: Bennet <bennet@zed.dev> Co-authored-by: Marshall Bowers <elliott.codes@gmail.com> Co-authored-by: Joseph T Lyons <JosephTLyons@gmail.com> Co-authored-by: Mikayla <mikayla@zed.dev> Co-authored-by: Jason <jason@zed.dev> Co-authored-by: Antonio Scandurra <me@as-cii.com> Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-authored-by: Marshall <marshall@zed.dev> Co-authored-by: Nathan Sobo <nathan@zed.dev> Co-authored-by: Jason Mancuso <7891333+jvmncs@users.noreply.github.com> Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
This commit is contained in:
parent
c633fa5a10
commit
eb3c4b0e46
100 changed files with 2564 additions and 457 deletions
|
@ -3,23 +3,23 @@
|
|||
Python support is available natively in Zed.
|
||||
|
||||
- Tree Sitter: [tree-sitter-python](https://github.com/tree-sitter/tree-sitter-python)
|
||||
- Language Server: [pyright](https://github.com/microsoft/pyright)
|
||||
- Language Server: [microsoft/pyright](https://github.com/microsoft/pyright)
|
||||
|
||||
### Configuration
|
||||
## Configuration
|
||||
|
||||
The [pyright](https://github.com/microsoft/pyright) language server offers flexible configuration options specified in a JSON-formatted text configuration. By default, the file is called `pyrightconfig.json` and is located within the root directory of your project. Pyright settings can also be specified in a `[tool.pyright]` section of a `pyproject.toml` file. A `pyrightconfig.json` file always takes precedent over `pyproject.toml` if both are present.
|
||||
The [pyright](https://github.com/microsoft/pyright) language server offers flexible configuration options specified in a JSON-formatted text configuration. By default, the file is called `pyrightconfig.json` and is located within the root directory of your project. Pyright settings can also be specified in a `[tool.pyright]` section of a `pyproject.toml` file. A `pyrightconfig.json` file always takes precedence over `pyproject.toml` if both are present.
|
||||
|
||||
For more information, see the Pyright [configuration documentation](https://microsoft.github.io/pyright/#/configuration).
|
||||
|
||||
### Settings
|
||||
## 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`.
|
||||
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
|
||||
- provide the path to a specific Python interpreter
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -41,9 +41,9 @@ For example, in order to:
|
|||
|
||||
For more information, see the Pyright [settings documentation](https://microsoft.github.io/pyright/#/settings).
|
||||
|
||||
### Virtual environments
|
||||
## 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.
|
||||
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.
|
||||
|
||||
By default, the Pyright language server will look for Python packages in the default global locations. But you can also configure Pyright to use the packages installed in a given virtual environment.
|
||||
|
||||
|
@ -54,7 +54,7 @@ To do this, create a JSON file called `pyrightconfig.json` at the root of your p
|
|||
|
||||
For example, a common approach is to create a virtual environment directory called `.venv` at the root of your project directory with the following commands:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
# create a virtual environment in the .venv directory
|
||||
python3 -m venv .venv
|
||||
# set up the current shell to use that virtual environment
|
||||
|
@ -78,7 +78,7 @@ 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).
|
||||
You can also configure this option directly in your `settings.json` file ([pyright settings](#settings)), as recommended in [Configuring Your Python Environment](https://microsoft.github.io/pyright/#/import-resolution?id=configuring-your-python-environment).
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -94,31 +94,13 @@ You can also configure this option directly in your `settings.json` file ([pyrig
|
|||
}
|
||||
```
|
||||
|
||||
### Code formatting & Linting
|
||||
## Code formatting & Linting
|
||||
|
||||
The Pyright language server does not provide code formatting or linting. If you want to detect lint errors and reformat your Python code upon saving, you'll need to set up.
|
||||
|
||||
A common tool for formatting Python code is [Ruff](https://docs.astral.sh/ruff/). It is another tool written in Rust, an extremely fast Python linter and code formatter.
|
||||
A common tool for formatting Python code is [Ruff](https://docs.astral.sh/ruff/). It is another tool written in Rust, an extremely fast Python linter and code formatter. It is available through the [Ruff extension](https://github.com/zed-industries/zed/tree/main/extensions/ruff/). To configure the Ruff extension to work within Zed, see the setup documentation [here](https://docs.astral.sh/ruff/editors/setup/#zed).
|
||||
|
||||
It is available through the [Ruff extension](https://github.com/zed-industries/zed/tree/main/extensions/ruff/). However, the code formatting through the extension is not yet available. You can set up the formatter to run on save by adding the following configuration to your `settings.json`, assuming that [`Ruff`](https://docs.astral.sh/ruff/) is installed in your Python environment.
|
||||
|
||||
```json
|
||||
{
|
||||
"languages": {
|
||||
..., // other languages
|
||||
"Python": {
|
||||
"format_on_save": {
|
||||
"external": {
|
||||
"command": "python",
|
||||
"arguments": [
|
||||
"-m",
|
||||
"ruff",
|
||||
"format",
|
||||
"-"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
<!--
|
||||
TBD: Expand Python Ruff docs.
|
||||
TBD: Ruff pyproject.toml, ruff.toml docs. `ruff.configuration`.
|
||||
-->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue