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
Originally posted by Lemour-sudo March 12, 2024
I see that we can use getWorkerUrl to run a custom worker.
However, I am not sure how to link this to the Editor component as the language property in the component is said to be for supported certain languages: https://github.com/microsoft/monaco-editor/tree/main/src/basic-languages
Is it possible to just have a custom language's server worker (e.g monaco-languageclient) integrated with this library's editor instead of relying on the hardcoded keywords and tokens?
Moreover, the label argument being passed to getWorker does not detect a custom registered language id. In the code snippet below, the logged label is just "editorWorkerService" instead of the registered "lingo" language id. Is this how it is meant to be used?
This is the snippet I have running using Vite:
import { useEffect } from "react";
import { loader } from "@monaco-editor/react";
import Editor, { useMonaco } from "@monaco-editor/react";
import editorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
const languageId = "lingo";
export function App() {
const monaco = useMonaco();
useEffect(() => {
if (monaco) {
monaco.languages.register({ id: languageId });
self.MonacoEnvironment = {
getWorker(_, label) {
console.log("label:", label);
return new editorWorker();
},
};
loader.config({ monaco });
}
}, [monaco]);
return (
<Editor
height="90vh"
defaultValue="// some comment"
language={languageId}
/>
);
}
```</div>
The text was updated successfully, but these errors were encountered:
Discussed in #594
Originally posted by Lemour-sudo March 12, 2024
I see that we can use
getWorkerUrl
to run a custom worker.However, I am not sure how to link this to the
Editor
component as thelanguage
property in the component is said to be for supported certain languages: https://github.com/microsoft/monaco-editor/tree/main/src/basic-languagesIs it possible to just have a custom language's server worker (e.g monaco-languageclient) integrated with this library's editor instead of relying on the hardcoded keywords and tokens?
Moreover, the
label
argument being passed togetWorker
does not detect a custom registered language id. In the code snippet below, the logged label is just "editorWorkerService" instead of the registered "lingo" language id. Is this how it is meant to be used?This is the snippet I have running using Vite:
The text was updated successfully, but these errors were encountered: