Skip to content

Conversation

daivinhtran
Copy link

@daivinhtran daivinhtran commented Sep 25, 2025

VSCode provides several ways to support highlighting

  1. TextMate grammars (similar to feat: add syntax highlighting for GritQL biome-intellij#195)
  2. Semantic Token Provider
    a. Using Regex to determine tokens
    b. Tree-sitter integration: Use tree-sitter-gritql and map syntax nodes to semantic tokens

This PR aims for 2.b. and implements a mapper from tree-sitter-gritql's syntax nodes [1] to VSCode's sematic tokens [2]. This is the cleanest way since we get to avoid the whole legwork of comprehending the GritQL grammar from the ground up.

[1] https://github.com/honeycombio/tree-sitter-gritql/blob/main/src/node-types.json
[2] https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#standard-token-types-and-modifiers

Screenshot 2025-10-09 at 6 21 44 PM

Fixes: #686

Checklist

  • I have tested my changes on the following platforms:
    • Windows
    • Linux
    • macOS

@daivinhtran daivinhtran requested review from a team and nhedger as code owners September 25, 2025 17:10
@daivinhtran daivinhtran force-pushed the gritql-token-provider branch 2 times, most recently from cbb9bb8 to c6569b9 Compare September 25, 2025 17:20
@daivinhtran daivinhtran changed the title Add minimal GritQL token provider feat: add minimal GritQL token provider Sep 25, 2025
@daivinhtran daivinhtran force-pushed the gritql-token-provider branch 3 times, most recently from 6f315cb to 11c60c1 Compare September 25, 2025 17:32
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Good start! I left some comments to address

@@ -0,0 +1,113 @@
import * as vscode from "vscode";

// TODO: Use tree-sitter for more accurate parsing once tree-sitter-gritql exports wasm file
Copy link
Member

Choose a reason for hiding this comment

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

This Todo should also explain how to address itself. Like, there's a reason why you couldn't implement it in this PR

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! I added more context in the TODO comment.

Essentially, honeycombio/tree-sitter-gritql#28 is the blocker.

@daivinhtran daivinhtran force-pushed the gritql-token-provider branch 2 times, most recently from d962d57 to 96d310c Compare September 26, 2025 18:57
Copy link
Author

@daivinhtran daivinhtran left a comment

Choose a reason for hiding this comment

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

Thanks @ematipico for reviewing. I cleaned up my the PR. PTAL!

I got my prototype for tree-sitter integration working in daivinhtran#1. honeycombio/tree-sitter-gritql#28 is the blocker before we can move forward with tree-sitter.

Anyways, this PR is a stepping stone and will make the work easier down the road.

@@ -0,0 +1,113 @@
import * as vscode from "vscode";

// TODO: Use tree-sitter for more accurate parsing once tree-sitter-gritql exports wasm file
Copy link
Author

Choose a reason for hiding this comment

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

Thanks! I added more context in the TODO comment.

Essentially, honeycombio/tree-sitter-gritql#28 is the blocker.

@daivinhtran daivinhtran changed the title feat: add minimal GritQL token provider feat: add regex-based GritQL token provider Sep 30, 2025
@daivinhtran daivinhtran changed the title feat: add regex-based GritQL token provider feat: add regex-based token provider for GritQL Sep 30, 2025
@daivinhtran daivinhtran requested a review from ematipico October 3, 2025 11:39
@daivinhtran daivinhtran force-pushed the gritql-token-provider branch from d9ccbe6 to f6b507e Compare October 9, 2025 11:40
@daivinhtran daivinhtran changed the title feat: add regex-based token provider for GritQL feat: add tree-sitter-based token provider for GritQL Oct 9, 2025
@daivinhtran
Copy link
Author

@ematipico I reworked the PR to integrate with tree-sitter since honeycombio/tree-sitter-gritql#28 is now resolved.

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

2 participants