undistro/cel-playground

Integrate tree-sitter-cel for highlighting

Alfus opened this issue · 4 comments

Alfus commented

Feature Description

Add tree-sitter based syntax highlighting

Additional Context

I created a tree-sitter grammar for cel: https://github.com/bufbuild/tree-sitter-cel with highlighting support. Would be cool to use it:
image

Hi @Alfus,
Thank you for the suggestion. Would really be nice to have a specific highlight for CEL.

Do you know any web code editor that supports tree-sitter grammar?

We're using ace that doesn't seem to support it.

Alfus commented

I've look around a bit, and all I can find is the c highlighting library and the tree-sitter-web query interface. I believe, if you feed in the highlights query file, it should return a query that can capture the nodes with their label (which has all the source location info).

Ideally this could then be mapped to a collection of source location + ace scope that ace understands, but the ace documentation doesn't show a way to bypass the regex based system they are using :-/.

Hello @Alfus, it could be an alternative, but perhaps considering the effort needed, it would be better to create a syntax highlighter in ace, since we don't know for sure there's a way to bypass the regex based system. Thoughts?

FWIW, there is an open issue related to tree-sitter support into the Ace code editor. Despite its presence, it appears that this issue has not received much attention or activity from the community.

Alfus commented

Reading that issue, it looks like it might actually be possible bypass the regex based highlighter and use tree-sitter; though, tree-sitter-web also uses wasm, to its a lot to pull in for just highlighting. I suspect this issue should wait for better tree-sitter support on both sides.