Create Language Server Protocol
Asked by Ankan Bhattacharya about 4 months ago
I was wondering how to create a language server protocol and connect it to react monaco editor? Also if we need to ship it using WASM... how can we do it?
2 Answers
-
setup a dedicated language server and use websocket to communicate between web app and language server - most online IDE use this method including codedamn, but to provide maximum isolation you have to setup a docker container for each IDE instance, it can be expensive and complex - java lsp example: https://github.com/thelonewolf123/monaco-lsp
-
You can run the language server inside a web worker and interface it with monaco. complexity wise it's simple but you can run only typescript and python lsp in this way - python client side lsp example: https://github.com/thelonewolf123/monaco-pyodide
To create a language server protocol, you will need to create an interface that will be used to communicate between the client (editor) and the language server (Best re-use the code for existing language servers). You can use Monaco Editor's Language Client API to connect it with React Monaco Editor. Not really sure about the WASM part though.
Hey Ankan,
To integrate autocomplete and intellisense with Monaco, you can do it in two ways,
If you want to setup language server for different language, change the binary path in createServerProcess
inside server.ts
and change the language scope to whatever language you want in editor.tsx