Skip to content

feat: add syntax highlighting rules for GritQL#150

Merged
dyc3 merged 2 commits into
biomejs:mainfrom
tidefield:gritql-syntax-highlighting
Sep 22, 2025
Merged

feat: add syntax highlighting rules for GritQL#150
dyc3 merged 2 commits into
biomejs:mainfrom
tidefield:gritql-syntax-highlighting

Conversation

@tidefield

@tidefield tidefield commented Sep 20, 2025

Copy link
Copy Markdown
Contributor

This PR introduces custom syntax highlighting rules for GritQL in Zed, relying on the official tree-sitter parser from honeycombio.

There are two building blockers that make up syntax highlighting

While we could use the recently released https://zed.dev/extensions/grit extension, it has a few limitations:

  1. Missing highlighting rules for regex, intConstant, signedIntConstant, arithmetic ops, multifile, etc
  2. Its underlying Tree-sitter parser is branched off from the official one
  3. Defines tab_size metadata which could conflict with biome formatter for GritQL.

Defining our own rules (as in this PR) allows us to ensure full coverage and compatibility, with minimal overhead. Relying on the official parser also makes future maintenance easier. Any custom syntax (e.g., ‎engine biome) can be contributed and converged with the official parser for broader support.

There are two TODO items I wish to accomplish after this PR:

  • Highlight engine biome in addition to engine marzano (requires upstream fix to tree-sitter parser)
  • Use Zed's code injection feature to properly highlight the code snippet inside GritQL.

See the screenshots below for a side-by-side comparison between our own rules and the GritQL extension.

Biome's rules Screenshot 2025-09-20 at 11 00 35 PM Screenshot 2025-09-20 at 10 55 32 PM Screenshot 2025-09-20 at 10 55 45 PM Screenshot 2025-09-20 at 10 55 54 PM Screenshot 2025-09-20 at 10 56 18 PM
Existing GritQL extension's rules Screenshot 2025-09-20 at 11 00 11 PM Screenshot 2025-09-20 at 10 57 49 PM Screenshot 2025-09-20 at 10 58 07 PM Screenshot 2025-09-20 at 10 58 25 PM Screenshot 2025-09-20 at 10 58 51 PM

Fixes: #125

@tidefield tidefield changed the title Add syntax highlighting rules for GritQL feat: Add syntax highlighting rules for GritQL Sep 20, 2025
@tidefield tidefield changed the title feat: Add syntax highlighting rules for GritQL feat: add syntax highlighting rules for GritQL Sep 20, 2025
@tidefield

Copy link
Copy Markdown
Contributor Author

If I can get biomejs/tree-sitter-gritql#25 approved, we can highlighting for the code snippet inside GritQL too (depending on whether we want it or not).

@tidefield

Copy link
Copy Markdown
Contributor Author

tidefield#1 with code injection, it looks awesome!

@tidefield

Copy link
Copy Markdown
Contributor Author

Thanks @siketyan for approving. What can I do to merge the PR?

@dyc3 dyc3 merged commit 1e84e10 into biomejs:main Sep 22, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add syntax highlighting for .grit files

4 participants