The rescript-vscode repository contains the LSP. It consists of a binary (known as the analysis binary) written in OCaml and a bit of TypeScript glue code.
One would need to use js_of_ocaml to create a JS bundle, similar to the playground and then somehow cobble it together with the TS part. Depending on your goals, you could also just use the analysis binary directly, as it has a very simple interface. However, having a real LSP is probably much more useful. It could enable us having an extension version for web editors.
Personally, I would love to have the analysis binary working in the playground itself, so you can explore the standard library easily thanks to autocompletion.
Thank you for your detailed + informative response.
I’m largely motivated by Try Eio and want to see if we can get the same with ReScript (which tends to compile faster than jsoo in my experience). Do we have the same goal in mind ?
Try-Eio also does not use any LSP from what I can see. It utilizes merlin-js instead. So the equivalent would be to use just the analysis binary compiled to JS via JSOO, I think.
Yes, I think you also just want the playground (or something like it) to support autocomplete and possibly other features.
Good call, to the best of my knowledge, it s using merlin-js, not any LSP. I got the two confused up.
On the editor side, do you have any advice on Monaco vs CodeMirror or something else? Approaches I’ve played with in the past:
Monaco: only played with JS/TS support, and it was toggling some switch, not actual code I wrote
CodeMirror: I got some codemirror lsp package (forgot which one) to rip out websockets and use postMessage to webworkers “work”, but it was very slow for completions
I did not practically tinker with it, but I’d still suggest to use CodeMirror, as it is also used by the ReScript playground. Have a look at repl.it’s assessment of it: Replit - Betting on CodeMirror
I don’t know from where the slowness comes, but the asynchronous nature of LSP could be the culprit. This may be another benefit of hooking up the analysis binary directly.