Open golok727 opened 3 months ago
What would be the API looks like in your mind?
What would be the API looks like in your mind?
Including the GrammarState in the TokensResult would be ideal.
class EditorTokensProvider {
// ...
tokenizeLine(line, state?: GrammarState) {
const {tokens, grammarState} = highligher.codeToTokens(code, {theme, grammarState: state, lang))
return {tokens: tokens[0], endState: grammarState }
}
//...
}
Additionally, could you provide a default static method in the GrammarState to get an initial state?
class GrammarState
{
static default(lang, theme)
{
return new GrammarState(INITIAL, lang, theme)
}
}
Thank you for this awesome project and for your time!
That would be a breaking change to the function unfortunately. We would need to find another non-breaking API for that
Clear and concise description of the problem
codeToTokens
to return the grammar state after tokenization.Suggested solution
This could be beneficial for tokenization in the editor I'm currently developing
Alternative
No response
Additional context
No response
Validations
Contributes