Skip to content
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

Explore using tree sitter for syntax highlighting #210475

Open
alexr00 opened this issue Apr 16, 2024 · 16 comments
Open

Explore using tree sitter for syntax highlighting #210475

alexr00 opened this issue Apr 16, 2024 · 16 comments
Assignees
Labels
exploration feature-request Request for new features or functionality grammar Syntax highlighting grammar
Milestone

Comments

@alexr00
Copy link
Member

alexr00 commented Apr 16, 2024

Goals of the explorations:

@alexr00
Copy link
Member Author

alexr00 commented May 3, 2024

Some notes on incremental parsing:

  • Per Can web-tree-sitter actually do async parsing? tree-sitter/tree-sitter#2118, it looks like we can set a timeout so that each call to parse times-out, with the parsing progress preserved for the next call to parse.
  • I've confirmed that this is the case; however, it appears to be broken in the latest version of web-tree-sitter. Going back to 0.22.2 works (latest is 0.22.5).
  • There does not appear to be any significant time penalty for setting a timeout.

@hediet FYI.

@alexr00
Copy link
Member Author

alexr00 commented May 6, 2024

Opened tree-sitter/tree-sitter#3341 for the above issue.

@alexr00
Copy link
Member Author

alexr00 commented May 28, 2024

After some discussion, we've decided to first understand the performance of using tree-sitter to parse files. #213565 contains that work.

@alexr00
Copy link
Member Author

alexr00 commented May 28, 2024

We also need new internal editor API to write a more optimal parse function, which @rebornix may help with.

@alexr00
Copy link
Member Author

alexr00 commented Jul 22, 2024

Progress in July:

alexr00 added a commit that referenced this issue Sep 23, 2024
* Colorization tests for tree sitter
Part of #210475

* Fix tests

* Actually fix tests

* Fix line endings
alexr00 added a commit that referenced this issue Sep 24, 2024
* Colorization tests for tree sitter
Part of #210475

* Fix tests

* Actually fix tests

* Fix line endings

* Register preferTreeSitter setting
@alexr00 alexr00 modified the milestones: October 2024, November 2024 Oct 4, 2024
@alexr00
Copy link
Member Author

alexr00 commented Nov 5, 2024

Updates (though I didn't get to work on this October):

  • We have syntax highlighting tests for tree sitter
  • Typescript is still the only supported language
  • Lots of small typescript improvements

For November, the main plan is performance.

alexr00 added a commit that referenced this issue Nov 5, 2024
* Add an easy way to run performance tests for tree-sitter
Part os #210475

* Compile build folder
@ghost
Copy link

ghost commented Nov 28, 2024

That's along of junk

@Plixo2
Copy link

Plixo2 commented Nov 29, 2024

Can we get an update on this?

@alexr00 alexr00 modified the milestones: November 2024, January 2025 Dec 3, 2024
@rzhao271 rzhao271 added the feature-request Request for new features or functionality label Dec 16, 2024
@ardokirsipuu
Copy link

ardokirsipuu commented Dec 30, 2024

Is this going to affect also Markdown? Asking because this task #180246 was closed without a fix (referencing to the abandoned TextMate's library) and this work here seems to be the only light at the end of the tunnel for resolving this.

@alexr00 Markdown wasn't part of your response here but there is a tree-sitter grammar for markdown existing, although it has some "interesting" comment about WASM, so I'm not sure if it will suite VS Code or not: https://github.com/tree-sitter-grammars/tree-sitter-markdown?tab=readme-ov-file#usage-with-wasm

Either way, should there be an open ticket to track this Markdown highlighting bug? So it would appear in this list.

@savetheclocktower
Copy link

although it has some "interesting" comment about WASM, so I'm not sure if it will suite VS Code or not: https://github.com/tree-sitter-grammars/tree-sitter-markdown?tab=readme-ov-file#usage-with-wasm

Pulsar got around this by building a custom copy of web-tree-sitter as described here. It's annoying, but not a deal-breaker.

@SeniorMars
Copy link

I'm putting this as a side note, but I'm sure solving the custom copy of web-tree-sitter problem would help (and be of interest) to Zed since I believe one of their goals is to be available through the web, too.

@alexr00
Copy link
Member Author

alexr00 commented Jan 6, 2025

Opened #237316 for markdown to keep it on my radar for either finding a new textmate grammar or considering for tree-sitter (depending on the situation with wasm).

@alexr00
Copy link
Member Author

alexr00 commented Jan 6, 2025

Actually, just re-opened #180246.

@alexr00 alexr00 closed this as completed Jan 6, 2025
@alexr00 alexr00 reopened this Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exploration feature-request Request for new features or functionality grammar Syntax highlighting grammar
Projects
None yet
Development

No branches or pull requests

7 participants