zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
39.61k stars 2.07k forks source link

Bracket pairing #4815

Open assayire opened 1 year ago

assayire commented 1 year ago

Check for existing issues

Describe the feature

As a Zed lover, I would love to have the feature to pair closing brackets. Example: When I type [, Zed should insert the matching pair ].

Here is a list of matching pairs that Zed should support:

This should be available under a setting that may be turned on or off by the user.

Bonus: The idea may be extended to HTML(-like) elements. Example: typing <div> should be matched with </div>. Just a passing mention here but there are other nuances to this which may be discussed outside this issue.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

altayevrim commented 4 months ago

Is there a feature to show or highlight the other part of the pair when I select one of the brackets? Or put my cursor next to it?

SomeoneToIgnore commented 4 months ago

Both features are there, language-dependent.

Brackets autoclose (if enabled in settings) is configured via language's config.toml file, e.g. https://github.com/zed-industries/zed/blob/d0eb15703006fea1208173059b29493b5201d4ec/crates/zed/src/languages/rust/config.toml

Brackets highlight is configured via language's tree-sitter queries in brackets.scm file, e.g. https://github.com/zed-industries/zed/blob/d0eb15703006fea1208173059b29493b5201d4ec/crates/zed/src/languages/rust/brackets.scm

zambetti commented 4 months ago

Related to this, does anyone know of a way to set the color/styling of the match pair highlight in a theme file?

Update I found it: editor.document_highlight.read_background