Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Backport `code_actions_on_format` docs and update them (#8881)

Thorsten Ball537d92533cee
diff --git a/docs/src/configuring_zed.md b/docs/src/configuring_zed.md
index 3323ea8c040..b2ae9ab86a8 100644
--- a/docs/src/configuring_zed.md
+++ b/docs/src/configuring_zed.md
@@ -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.