Allow user to use multiple formatters (#14846)

Fixes #4822
- [x] Release note
- [ ] Surface formatting errors via a toast
- [x] Doc updates
- [x] Have "language-server" accept an optional name of the server.

Release Notes:

- `format` and `format_on_save` now accept an array of formatting
actions to run.
- `language_server` formatter option now accepts the name of a language
server to use (e.g. `{"language_server": {"name: "ruff"}}`); when not
specified, a primary language server is used.

---------

Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
Piotr Osiewicz 2024-07-23 20:05:09 +02:00 committed by GitHub
parent 53b711c2b4
commit 3d1bf09299
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 565 additions and 130 deletions

View file

@ -601,6 +601,21 @@ To override settings for a language, add an entry for that language server's nam
}
```
4. Or to use multiple formatters consecutively, use an array of formatters:
```json
{
"formatter": [
{"language_server": {"name": "rust-analyzer"}},
{"external": {
"command": "sed",
"arguments": ["-e", "s/ *$//"]
}
]
}
```
Here `rust-analyzer` will be used first to format the code, followed by a call of sed.
If any of the formatters fails, the subsequent ones will still be executed.
## Code Actions On Format
- Description: The code actions to perform with the primary language server when formatting the buffer.