Add Monarch tokenization to Editor code pane for CascadeStudio and OpenSCAD. #247
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I was in the mood to have a crack at this, and I didn't get very far, but I found a couple things that might be useful.
First of all I thought there might be a way to side step the Monarch tokenisation completely by using this textmate language file for openscad.
https://github.com/tbuser/openscad.tmbundle/blob/master/Syntaxes/OpenSCAD.tmLanguage
However I've since learnt that tmLanguage files rely specifically on
Cregex of which the javascript regex is not compatible. There's this as a work around that leading theCregex in as a wasm filehttps://www.npmjs.com/package/monaco-editor-textmate
But I wasn't super keen on adding another wasm file, also because the OpenSCAD language is pretty simple so implementing highlighting doesn't seem too crazy to me.
However I've not been able to find examples of folks defining languages with the react monaco-editor. So instead I was trying to use this as an example.
https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-custom-languages
Trying to call the same functions in the
beforeMountcallbackhttps://github.com/suren-atoyan/monaco-react#monaco-instance
But alas some dots mustn't be connected as I never got any highlighting to work.
I had missed the line
monaco.languages.register({ id: 'openscad' })🤦 got something basic working but really only played with it. There's a lot to learn on how to match text for highlighting.Some really cool things that we could do though, There's the hover provider example
https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-hover-provider-example
We could offer inline docs.