TypeFox / monaco-languageclient

Repo hosts npm packages for monaco-languageclient, vscode-ws-jsonrpc, monaco-editor-wrapper, @typefox/monaco-editor-react and monaco-languageclient-examples
https://www.npmjs.com/package/monaco-languageclient
MIT License
1.07k stars 180 forks source link

Using monaco-languageclient with React and an Existing Worker from Langium #608

Closed Lemour-sudo closed 8 months ago

Lemour-sudo commented 8 months ago

I am trying to setup monaco-languageclient to work with the monaco-react Editor component and I need a guide on how to connect the two and have the auto-complete working too from an existing web worker for a custom language (defined in Langium).

From my limited understanding the "language-configuration.json", "statemachine.tmLanguage.json" and "statemachineServerWorker.js" files should be sufficient to have the grammar loaded and auto-complete working.

I setup an experimental repo (https://github.com/Lemour-sudo/monaco-react-example) to first work with the basic state-machine example to try this.

Everything builds well but the language client fails to start and throws the error TypeError: this._fileService.onWillActivateFileSystemProvider is not a function in the browser.

An explanation and a guide would help on how to do this. And can the ReadMe be updated for the new versions of the language-client being released along with the updated package.json in the examples workspace? It is quite a struggle to find the correct exact dependencies that work.

empfaze commented 8 months ago

@Lemour-sudo I have the same error, when trying to implement my custom LSP with React. I think that the error occurs when we trying to initialize userServices with "initServices" from "monaco-languageclient". But I also don't know how to handle this. In the end in console log we should see the message about successful services initialization. You can see it in Typefox React example.

kaisalmen commented 8 months ago

@Lemour-sudo #600 will introduce https://www.npmjs.com/package/@typefox/monaco-editor-react and https://www.npmjs.com/package/monaco-editor-wrapper into this repo and the examples will make use of it. This will reduce the amount of boiler plate code and configuration. It should be in by the end of the week. 🤞

Lemour-sudo commented 8 months ago

Thank you for the replies.

I see that version 8.0.0-next.3 solves a lot of dependency issues and I managed to run it successfully too. @kaisalmen Any estimate of when the final version 8.0.0 will be out yet?

kaisalmen commented 8 months ago

I see that version 8.0.0-next.3 solves a lot of dependency issues and I managed to run it successfully too

@Lemour-sudo yes, overrides are no longer necessary (next.4 releases are available now)

Any estimate of when the final version 8.0.0 will be out yet?

Release hopefully before end of the week. Documentation needs a huge overhaul.

Lemour-sudo commented 8 months ago

Great work! Thanks @kaisalmen !