-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Custom syntax highlighting using tree-sitter #4674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
For syntax highlighting Ace needs an object with getLineTokens method https://github.com/ajaxorg/ace/blob/v1.4.14/lib/ace/background_tokenizer.js#L234 which returns an object like The state is needed for editor to know if highlighting have changed after that line and editor needs to rerender more lines or not. It appears that it should be possible to convert output of tree sitter into a format usable by ace, but if tree-sitter provides only async api, it is also possible to replace bg-tokenizer entirely and rely on tree sitter itself ofr caching and incremental highlighting. Atom code can be a useful starting point in implementing this https://github.com/atom/atom/blob/9826355da0a52509a84448d86c2c9a935e447aab/src/tree-sitter-language-mode.js |
Thanks @nightwing! I don't think tree-sitter supports parsing line-by-line, could you elaborate more on how I could replace the BackgroundTokenizer entirely? |
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
I'd still love to see tree-sitter support (or custom syntax highlighting support) in Ace. |
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
@nightwing @andrewnester can this be reopened? It is still relevant |
Reopening per request from the community above |
I would like to use this library to make mustache documents editable. I guess I would also benefit from this library supporting highlighting any grammar-provided languages? |
Hi, I'm trying to use Ace as an online editor for a new language. I already have a grammar written in
tree-sitter
, I'm wondering if I can somehow reuse that for highlighting rather than writing yet another grammar for Ace.Is it possible to use tree-sitter with Ace directly, or bypass the builtin highlighter and manually define my own one?
The text was updated successfully, but these errors were encountered: