undistro / cel-playground

CEL Playground provides a simple and user-friendly interface to write and quickly evaluate CEL expressions.
https://playcel.undistro.io
Apache License 2.0
117 stars 20 forks source link

Integrate tree-sitter-cel for highlighting #14

Open Alfus opened 1 year ago

Alfus commented 1 year ago

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

matheusfm commented 1 year ago

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 1 year ago

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 :-/.

monuelo commented 1 year ago

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 1 year ago

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.