docs: Formatter arguments, document {buffer_path} usage (#19156)

This commit is contained in:
Peter Tripp 2024-10-13 10:25:08 -04:00 committed by GitHub
parent 39468de8c6
commit cdead5760a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -739,7 +739,18 @@ While other options may be changed at a runtime and should be placed under `sett
}
```
3. Or to use code actions provided by the connected language servers, use `"code_actions"`:
3. External formatters may optionally include a `{buffer_path}` placeholder which at runtime will include the path of the buffer being formatted. Formatters operate by receiving file content via standard input, reformatting it and then outputting it to standard output and so normally don't know the filename of what they are formatting. Tools like prettier support receiving the file path via a command line argument which can then used to impact formatting decisions.
```json
"formatter": {
"external": {
"command": "prettier",
"arguments": ["--stdin-filepath", "{buffer_path}"]
}
}
```
4. Or to use code actions provided by the connected language servers, use `"code_actions"`:
```json
{
@ -754,7 +765,7 @@ While other options may be changed at a runtime and should be placed under `sett
}
```
4. Or to use multiple formatters consecutively, use an array of formatters:
5. Or to use multiple formatters consecutively, use an array of formatters:
```json
{