-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
Make grammar state working with themes
instead of just theme
#734
Comments
Im dealing with the same problem right now too. I read the code. I think
Finally, I think maybe should export this |
@uxiew I don't get it.
Why is that? the grammar state is just a state that will be passed into functions like Or alternatively, the quick solution could be if |
True. Anyway it makes no sense to complain about the theme mismatch, where the theme/themes from high-level functions like I currently don't have time capacity to look into the code and provide a PR, but that's really a huge headache, which means I can't really use GrammarState in an app with two themes, otherwise it's not looking good at all🤦♀️ |
@antfu Sorry for pining straight away, first of all, I really appreciate your hard work on the grammar state as it really helps a lot to annotate types independently. Since you are the one who implemented the grammar state feature, can you please post some comments/thoughts about why it requires theme context and why it only accepts a single theme instead of If you can share some thoughts there, maybe some other folks can have a look into it, as currently it really struggles with theme toggling. Thanks 💖 |
The problem is that both theme and grammar would affect how tokens been generated. The current multiple themes approach is done by taking two passes with different themes, and then "sync" the tokens split points. Which means in this process, there are actually two or multiple pipeline of "grammar state" been generated. Supposely that we only return the state of the first themes. So this problem is rather tricky to handle, we either:
Either way, I don't think I have enough bandwidth or incentive to work on that. I would count on the community's contributions. |
Clear and concise description of the problem
Currently it's not allowing to use
themes
when passing grammar state intocodeToHtml
Either way it's not going to work no matter I specify theme in
.getLastGrammarState
or not. Seems it defaults to the first loaded theme.See the below example.
Also, seems the grammar state is not in the documentation, so I have to follow the guide in the PR and from TS types.
e.g.
Suggested solution
allow
themes
in.getLastGrammarState()
, or simply removetheme
from the function.I've no idea how it's working under the hood, but it's a bit weird to me since we are passing the grammar state to the render function, where
theme
orthemes
has to be provided, then why do we still need to pass it to grammar state?Alternative
No response
Additional context
No response
Validations
Contributes
The text was updated successfully, but these errors were encountered: