Support bracket colorization (rainbow brackets) (#43172)
Deals with https://github.com/zed-industries/zed/issues/5259 Highlights brackets with different colors based on their depth. Uses existing tree-sitter queries from brackets.scm to find brackets, uses theme's accents to color them. https://github.com/user-attachments/assets/cc5f3aba-22fa-446d-9af7-ba6e772029da 1. Adds `colorize_brackets` language setting that allows, per language or globally for all languages, to configure whether Zed should color the brackets for a particular language. Disabled for all languages by default. 2. Any given language can opt-out a certain bracket pair by amending the brackets.scm like `("\"" @open "\"" @close) ` -> `(("\"" @open "\"" @close) (#set! rainbow.exclude))` 3. Brackets are using colors from theme accents, which can be overridden as ```jsonc "theme_overrides": { "One Dark": { "accents": ["#ff69b4", "#7fff00", "#ff1493", "#00ffff", "#ff8c00", "#9400d3"] } }, ``` Release Notes: - Added bracket colorization (rainbow brackets) support. Use `colorize_brackets` language setting to enable. --------- Co-authored-by: MrSubidubi <dev@bahn.sh> Co-authored-by: Lukas Wirth <lukas@zed.dev> Co-authored-by: MrSubidubi <finn@zed.dev> Co-authored-by: Lukas Wirth <me@lukaswirth.dev> Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This commit is contained in:
co-authored by
MrSubidubi
Lukas Wirth
MrSubidubi
Lukas Wirth
Smit Barmase
parent
e6e5ccbf10
commit
7e341bcf94
@@ -196,6 +196,7 @@ You can also add agents through your `settings.json`, by specifying certain fiel
|
||||
{
|
||||
"agent_servers": {
|
||||
"My Custom Agent": {
|
||||
"type": "custom",
|
||||
"command": "node",
|
||||
"args": ["~/projects/agent/index.js", "--acp"],
|
||||
"env": {}
|
||||
|
||||
@@ -58,6 +58,7 @@ You can customize a wide range of settings for each language, including:
|
||||
- [`soft_wrap`](./configuring-zed.md#soft-wrap): How to wrap long lines of code
|
||||
- [`show_completions_on_input`](./configuring-zed.md#show-completions-on-input): Whether or not to show completions as you type
|
||||
- [`show_completion_documentation`](./configuring-zed.md#show-completion-documentation): Whether to display inline and alongside documentation for items in the completions menu
|
||||
- [`colorize_brackets`](./configuring-zed.md#colorize-brackets): Whether to use tree-sitter bracket queries to detect and colorize the brackets in the editor (also known as "rainbow brackets")
|
||||
|
||||
These settings allow you to maintain specific coding styles across different languages and projects.
|
||||
|
||||
|
||||
@@ -4687,6 +4687,18 @@ See the [debugger page](./debugger.md) for more information about debugging supp
|
||||
},
|
||||
```
|
||||
|
||||
## Colorize Brackets
|
||||
|
||||
- Description: Whether to use tree-sitter bracket queries to detect and colorize the brackets in the editor (also known as "rainbow brackets").
|
||||
- Setting: `colorize_brackets`
|
||||
- Default: `false`
|
||||
|
||||
**Options**
|
||||
|
||||
`boolean` values
|
||||
|
||||
The colors that are used for different indentation levels are defined in the theme (theme key: `accents`). They can be customized by using theme overrides.
|
||||
|
||||
## Unnecessary Code Fade
|
||||
|
||||
- Description: How much to fade out unused code.
|
||||
|
||||
@@ -154,6 +154,14 @@ This query identifies opening and closing brackets, braces, and quotation marks.
|
||||
| @open | Captures opening brackets, braces, and quotes |
|
||||
| @close | Captures closing brackets, braces, and quotes |
|
||||
|
||||
Zed uses these to highlight matching brackets: painting each bracket pair with a different color ("rainbow brackets") and highlighting the brackets if the cursor is inside the bracket pair.
|
||||
|
||||
To opt out of rainbow brackets colorization, add the following to the corresponding `brackets.scm` entry:
|
||||
|
||||
```scheme
|
||||
(("\"" @open "\"" @close) (#set! rainbow.exclude))
|
||||
```
|
||||
|
||||
### Code outline/structure
|
||||
|
||||
The `outline.scm` file defines the structure for the code outline.
|
||||
|
||||
+9
-1
@@ -51,7 +51,15 @@ For example, add the following to your `settings.json` if you wish to override t
|
||||
"comment.doc": {
|
||||
"font_style": "italic"
|
||||
}
|
||||
}
|
||||
},
|
||||
"accents": [
|
||||
"#ff0000",
|
||||
"#ff7f00",
|
||||
"#ffff00",
|
||||
"#00ff00",
|
||||
"#0000ff",
|
||||
"#8b00ff"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,6 +374,8 @@ TBD: Centered layout related settings
|
||||
"lsp_document_colors": "inlay", // none, inlay, border, background
|
||||
// When to show the scrollbar in the completion menu.
|
||||
"completion_menu_scrollbar": "never", // auto, system, always, never
|
||||
// Turn on colorization of brackets in editors (configurable per language)
|
||||
"colorize_brackets": true,
|
||||
```
|
||||
|
||||
### Edit Predictions {#editor-ai}
|
||||
|
||||
Reference in New Issue
Block a user