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

Support for incremental tokenization #419

Closed
fabiospampinato opened this issue Jan 22, 2023 · 9 comments
Closed

Support for incremental tokenization #419

fabiospampinato opened this issue Jan 22, 2023 · 9 comments

Comments

@fabiospampinato
Copy link

It'd be very interesting for some applications if Shiki supported tokenizing incrementally, basically something that editors like vscode might want to use.

@muenzpraeger
Copy link
Collaborator

Out of curiosity: what would be the use case for incremental tokenization?

@fabiospampinato
Copy link
Author

My use case would be building a new editor, I can't stop the world when tokenizing a document, and I can't restart tokenization from scratch when a new line is appended to the document, for example.

@muenzpraeger
Copy link
Collaborator

So your use case is around general tokenization of a given string/line of code based on a tmLanguage definition, and not (static) syntax highlighting?

@fabiospampinato
Copy link
Author

Yes.

@orta
Copy link
Contributor

orta commented Jan 22, 2023

Realistically shiki is too high level of an abstraction for you to do that, you're probably wanting to use the APIs from vscode-oniguruma & vscode-textmate yourself

@fabiospampinato
Copy link
Author

Makes sense, thanks 👍

@octref
Copy link
Collaborator

octref commented Jan 27, 2023

I'd say look into tree-sitter.

@fabiospampinato
Copy link
Author

Tree-sitter is interesting, but it doesn't support as many grammars as TextMate and the syntax highlighting would be slightly different compared to vscode, which I guess would be undesirable, even if it's slightly better.

I'd like to add support for both eventually though, for the moment I've only wired textmate grammars in.

@tats-u
Copy link

tats-u commented Mar 10, 2025

@fabiospampinato VS Code started to implement this feature: microsoft/vscode#210475
You do not have to throw away the current TextMate syntax assets; only supported languages are fine.
Could you reconsider this feature in shiki?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants