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 · 30 comments
Open

Explore using tree sitter for syntax highlighting #210475

alexr00 opened this issue Apr 16, 2024 · 30 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 Feb 12, 2025
alexr00 added a commit that referenced this issue Feb 13, 2025
* Use tree sitter for ini
Part of #210475

* Include ini in tree sitter colorization tests

* Remove /r
alexr00 added a commit that referenced this issue Feb 13, 2025
alexr00 added a commit that referenced this issue Feb 13, 2025
* Change tree sitter setting to be per langauge
Part of #210475

* Fix accidentally unregistering languages
@usernamehw
Copy link
Contributor

Will using Tree Sitter make it easier to implement this (10yo) extension api feature #580 - get scopes at Position/Range?

@RedCMD
Copy link
Contributor

RedCMD commented Feb 15, 2025

@usernamehw
yes

@alexr00
is there any time frame for giving extensions access?
proposed api?

@alexr00
Copy link
Member Author

alexr00 commented Feb 17, 2025

No time frame at the moment.

alexr00 added a commit that referenced this issue Feb 18, 2025
* Enable bracket features with tree sitter and fix template strings
Part of #210475

* Fix force tokenization
@alexr00 alexr00 modified the milestones: February 2025, March 2025 Feb 24, 2025
@alexr00
Copy link
Member Author

alexr00 commented Feb 24, 2025

End of Febuary updates:

  • Viewport is colored first
  • Existing bracket features enabled
  • Themes that target multiple scopes enabled
  • We're rolling out tree sitter based syntax highlighting for ini files in insiders
  • Improvements to typescript highlighting

@usernamehw
Copy link
Contributor

Is it possible for color themes to use scopes provided by tree-sitter?

@alexr00
Copy link
Member Author

alexr00 commented Feb 27, 2025

Currently, only scopes listed in the highligths file are available, though I'm ading more to that as we find things missing that existing themes need.

Once we have a contribution story, I think we would allow extensions to contribute an scm file like that.

@tats-u
Copy link
Contributor

tats-u commented Mar 9, 2025

If the current language lacks the tree-sitter syntax, VS Code should fall back to the current TextMate highlight syntax.

@RedCMD
Copy link
Contributor

RedCMD commented Mar 10, 2025

@tats-u that is the current plan

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