Open Irev-Dev opened 3 years ago
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.
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
C
regex of which the javascript regex is not compatible. There's this as a work around that leading theC
regex in as a wasm file https://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
beforeMount
callback https://github.com/suren-atoyan/monaco-react#monaco-instanceBut alas some dots mustn't be connected as I never got any highlighting to work.