docs: Formatter arguments, document {buffer_path}
usage (#19156)
This commit is contained in:
parent
39468de8c6
commit
cdead5760a
1 changed files with 13 additions and 2 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue