Skip to content

Replace highlight captures that don't work in Zed#52

Merged
MrSubidubi merged 2 commits into
zed-extensions:mainfrom
keufcp:fix-zed-highlight-captures
Jul 20, 2026
Merged

Replace highlight captures that don't work in Zed#52
MrSubidubi merged 2 commits into
zed-extensions:mainfrom
keufcp:fix-zed-highlight-captures

Conversation

@keufcp

@keufcp keufcp commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Problem

languages/sql/highlights.scm contains patterns that appear to have been carried over from nvim-treesitter and do not work in Zed:

  1. The #match? predicates for numeric literals use Lua-style character classes (%d), which Zed's (Rust) regex engine never matches. As a result, all numeric literals fall through to the earlier (literal) @string capture and are highlighted as strings.
  2. @float is not a syntax style that exists in Zed themes, so even if the predicate matched, float literals would be unstyled.
  3. @field is not a capture that maps to any Zed theme style either, so Zed silently discards it and column names fall back to the earlier (identifier) @variable capture instead of being styled as properties.

Partially addresses the "inconsistent highlighting" reports in #37 (string-colored numbers).

Changes

  • Replace %d with \d in the #match? predicates
  • Replace @float with @number (Zed has no float style)
  • Replace @field with @property (Zed has no field style)

Before / After

Before After
Numeric literals (100.25, 1.08, 5) string color number color
One Dark 024 025
vscode-dark-polished 023 022

@field@property has no visual effect in themes where variable and property share a color (e.g. VS Code Dark Modern derivatives), but it makes column names use the intended property style instead of falling back to @variable via Zed silently discarding the unknown @field capture.

Not addressed (grammar-level, out of scope)

These remain unhighlighted because tree-sitter-sql cannot parse them, which a query-only change cannot fix:

  • SAVEPOINT statements
  • Dollar-quoted strings ($$ ... $$), e.g. plpgsql function bodies
  • String literals following INTERVAL

- replace Lua-style %d in #match? predicates with \d: Zed's regex
  engine never matched them, so numeric literals fell through to
  the @string capture
- replace @float with @Number: Zed themes have no "float" style
- replace @field with @Property: Zed themes have no "field" style,
  leaving column names unstyled
Copilot AI review requested due to automatic review settings July 9, 2026 12:33
@cla-bot cla-bot Bot added the cla-signed label Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@MrSubidubi MrSubidubi changed the title fix: replace highlight captures that don't work in Zed Replace highlight captures that don't work in Zed Jul 20, 2026

@MrSubidubi MrSubidubi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very nice, thank you!

@MrSubidubi
MrSubidubi merged commit 3d67415 into zed-extensions:main Jul 20, 2026
5 checks passed
@keufcp
keufcp deleted the fix-zed-highlight-captures branch July 20, 2026 20:51
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.

3 participants