Closes #ISSUE Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -320,8 +320,8 @@ To run linter fixes automatically on save:
|
||||
```json
|
||||
"languages": {
|
||||
"JavaScript": {
|
||||
"code_actions_on_format": {
|
||||
"source.fixAll.eslint": true
|
||||
"formatter": {
|
||||
"code_action": "source.fixAll.eslint"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -334,15 +334,17 @@ Zed allows you to run both formatting and linting on save. Here's an example tha
|
||||
```json
|
||||
"languages": {
|
||||
"JavaScript": {
|
||||
"formatter": {
|
||||
"external": {
|
||||
"command": "prettier",
|
||||
"arguments": ["--stdin-filepath", "{buffer_path}"]
|
||||
"formatter": [
|
||||
{
|
||||
"code_action": "source.fixAll.eslint"
|
||||
},
|
||||
{
|
||||
"external": {
|
||||
"command": "prettier",
|
||||
"arguments": ["--stdin-filepath", "{buffer_path}"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"code_actions_on_format": {
|
||||
"source.fixAll.eslint": true
|
||||
},
|
||||
],
|
||||
"format_on_save": "on"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1745,74 +1745,6 @@ WARNING: `{buffer_path}` should not be used to direct your formatter to read fro
|
||||
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.
|
||||
- Setting: `code_actions_on_format`
|
||||
- Default: `{}`, except for Go it's `{ "source.organizeImports": true }`
|
||||
|
||||
**Examples**
|
||||
|
||||
<!--
|
||||
TBD: Add Python Ruff source.organizeImports example
|
||||
-->
|
||||
|
||||
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:
|
||||
|
||||
```json
|
||||
{
|
||||
"languages": {
|
||||
"JavaScript": {
|
||||
"code_actions_on_format": {
|
||||
"source.fixAll.eslint": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. Run only a single ESLint rule when using `fixAll`:
|
||||
|
||||
```json
|
||||
{
|
||||
"languages": {
|
||||
"JavaScript": {
|
||||
"code_actions_on_format": {
|
||||
"source.fixAll.eslint": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"lsp": {
|
||||
"eslint": {
|
||||
"settings": {
|
||||
"codeActionOnSave": {
|
||||
"rules": ["import/order"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Auto close
|
||||
|
||||
- Description: Whether to automatically add matching closing characters when typing opening parenthesis, bracket, brace, single or double quote characters.
|
||||
|
||||
@@ -49,8 +49,8 @@ You can configure Zed to format code using `eslint --fix` by running the ESLint
|
||||
{
|
||||
"languages": {
|
||||
"JavaScript": {
|
||||
"code_actions_on_format": {
|
||||
"source.fixAll.eslint": true
|
||||
"formatter": {
|
||||
"code_action": "source.fixAll.eslint"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,8 +63,8 @@ You can also only execute a single ESLint rule when using `fixAll`:
|
||||
{
|
||||
"languages": {
|
||||
"JavaScript": {
|
||||
"code_actions_on_format": {
|
||||
"source.fixAll.eslint": true
|
||||
"formatter": {
|
||||
"code_action": "source.fixAll.eslint"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user