Skip to content

Exclude markup punctuation from rainbow brackets - #94

Open
MartinoPolo wants to merge 1 commit into
zed-extensions:mainfrom
MartinoPolo:exclude-markup-punctuation-from-rainbow-brackets
Open

MartinoPolo wants to merge 1 commit into
zed-extensions:mainfrom
MartinoPolo:exclude-markup-punctuation-from-rainbow-brackets

Conversation

@MartinoPolo

@MartinoPolo MartinoPolo commented Aug 18, 2026 •

Copy link
Copy Markdown

Problem

With "colorize_brackets": true (rainbow brackets), Zed colors every pair declared in brackets.scm from the theme's accents array, by nesting depth. That overrides the theme's syntax colors for those tokens.

In Svelte files this hits the markup punctuation:

  • < and > are painted from accents instead of the theme's tag.punctuation.bracket
  • attribute quotes are painted from accents instead of the theme's string, so class="foo" shows gold delimiters around a differently-colored body

It also renders inconsistently, which is what makes it look like a bug rather than a preference. ("<" @open ">" @close) matches < and > only as siblings, and that only happens in a start tag — an end tag is </ … > (no < token) and a self-closing tag is < … /> (no > token). So <div …> is rainbow-colored while the </div> closing it keeps the theme color.

Fix

Mark those pairs rainbow.exclude, which is what the bundled HTML extension already does for its tag punctuation and quotes:

{} and () are left rainbow-colored — mustache blocks and expressions are where the feature actually earns its keep in Svelte markup. Bracket matching and the newline.only indent behavior are unchanged; rainbow.exclude only opts the pair out of colorization.

Testing

Applied to the installed extension copy on Zed 1.15 (Windows) with colorize_brackets: true. Angle brackets and attribute quotes now follow the theme, start and end tags match each other, and {} / () still cycle through the accent colors.

@cla-bot

cla-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @MartinoPolo on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@MartinoPolo

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Aug 18, 2026
@cla-bot

cla-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

`colorize_brackets` colors every pair listed in `brackets.scm` from the
theme's `accents`, by nesting depth. For Svelte that overrode the theme's
`tag.punctuation.bracket` on `<` and `>`, and `string` on attribute quotes.

The result was also inconsistent: `("<" @OPEN ">" @close)` only matches
`<` and `>` as siblings, which happens in a start tag but not in an end
tag (`</` … `>`) or a self-closing tag (`<` … `/>`), so start tags were
rainbow-colored while the tags closing them stayed the theme color.

Mark those pairs `rainbow.exclude`, as the bundled HTML extension already
does. `{}` and `()` keep their rainbow colors, which is where the feature
is actually useful in Svelte markup.
@MartinoPolo
MartinoPolo force-pushed the exclude-markup-punctuation-from-rainbow-brackets branch from aa6997c to ae5147b Compare August 18, 2026 14:17

@ghostdevv ghostdevv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you share some before/after screenshots?

@MartinoPolo

MartinoPolo commented Aug 19, 2026 •

Copy link
Copy Markdown
Author

Subtle but important difference - Focus on the color of <> in script tag and component call sites.

Before
befor - wrong
After
after

Before
befor - wrong2

After
after2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants