You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having a setup with Rust and WASM, I do have the problem that I can't pass in the monaco parameter to the wireGrammar function. There is no type/instance for the namespace.
However, using an existing wrapper for the monco editor, I already have the API available for calling monaco.languages.setTokensProvider. If I would have an instance to set.
Unfortunately, this is hidden in the wireTmGrammars. It would be great if the API could be extended, to offer some createProvider function, which creates the provider instance, but not setting it.
Something like:
exportfunctioncreateProvider(grammar: IGrammar,editor?: monacoNsps.editor.ICodeEditor) : TokensProvider{return{getInitialState: ()=>newTokenizerState(INITIAL),tokenize: (line: string,state: TokenizerState)=>{constres=grammar.tokenizeLine(line,state.ruleStack)return{endState: newTokenizerState(res.ruleStack),tokens: res.tokens.map(token=>({
...token,// TODO: At the moment, monaco-editor doesn't seem to accept array of scopesscopes: editor ? TMToMonacoToken(editor,token.scopes) : token.scopes[token.scopes.length-1]})),}}}}exportfunctionwireTmGrammars(monaco: typeofmonacoNsps,registry: Registry,languages: Map<string,string>,editor?: monacoNsps.editor.ICodeEditor){returnPromise.all(Array.from(languages.keys()).map(async(languageId)=>{constgrammar=awaitregistry.loadGrammar(languages.get(languageId))constprovider=createProvider(grammar,editor);monaco.languages.setTokensProvider(languageId,provider)}))}
This would allow one to re-use as much code as possible, but performing the task of setting the tokens provider manually.
The text was updated successfully, but these errors were encountered:
Having a setup with Rust and WASM, I do have the problem that I can't pass in the
monaco
parameter to thewireGrammar
function. There is no type/instance for the namespace.However, using an existing wrapper for the monco editor, I already have the API available for calling
monaco.languages.setTokensProvider
. If I would have an instance to set.Unfortunately, this is hidden in the
wireTmGrammars
. It would be great if the API could be extended, to offer somecreateProvider
function, which creates the provider instance, but not setting it.Something like:
This would allow one to re-use as much code as possible, but performing the task of setting the tokens provider manually.
The text was updated successfully, but these errors were encountered: