Backport code_actions_on_format docs and update them (#8881)

Release Notes:

- N/A
This commit is contained in:
Thorsten Ball 2024-03-05 11:06:49 +01:00 committed by GitHub
parent fae5e83d93
commit 537d92533c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -306,6 +306,70 @@ To override settings for a language, add an entry for that language server's nam
}
```
## Code Actions On Format
- Description: The code actions to perform with the primary language server when formatting the buffer.
- Setting: `code_actions_on_format`
- Default: `{}`, except for Go it's `{ "source.organizeImports": true }`
**Examples**
1. Organize imports on format in TypeScript and TSX buffers:
```json
{
"languages": {
"TypeScript": {
"code_actions_on_format": {
"source.organizeImports": true
}
},
"TSX": {
"code_actions_on_format": {
"source.organizeImports": true
}
}
}
}
```
2. Run ESLint `fixAll` code action when formatting (requires Zed `0.125.0`):
```json
{
"languages": {
"JavaScript": {
"code_actions_on_format": {
"source.fixAll.eslint": true
}
}
}
}
```
3. Run only a single ESLint rule when using `fixAll` (requires Zed `0.125.0`):
```json
{
"languages": {
"JavaScript": {
"code_actions_on_format": {
"source.fixAll.eslint": true
}
}
},
"lsp": {
"eslint": {
"settings": {
"codeActionOnSave": {
"rules": ["import/order"]
}
}
}
}
}
```
## Auto close
- Description: Whether or not to automatically type closing characters for you.