Skip to content

Instantly share code, notes, and snippets.

@davesnx
Last active September 10, 2021 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davesnx/5018c941974c2524e9e4cba6ec3dcd51 to your computer and use it in GitHub Desktop.
Save davesnx/5018c941974c2524e9e4cba6ec3dcd51 to your computer and use it in GitHub Desktop.
Using ocaml-lsp with Reason syntax

Configure VSCode with ocaml-lsp, esy and Reason syntax with ReScript/bs-platform.

It's a non-common setup

but I find very useful, I keep liking more the Reason syntax and the ocaml-lsp experience it's much better than the rescript extension. Notably with the CodeLens support https://code.visualstudio.com/blogs/2017/02/12/code-lens-roundup with https://github.com/ocaml/ocaml-lsp.

So, If you want to keep using Reason syntax targeting the browser/node and have a good editor support, follow this:

Requirements

$ esy --version
0.6.11

Add dependencies (or devDependencies) in esy

$ cat esy.json

{
  "dependencies": {
    "@opam/ocaml-lsp-server": "1.4.1",
    "@opam/dune": "2.5.1",
    "@opam/ocamlfind-secondary": "1.8.1",
    "@opam/reason": "3.6.0",
    "ocaml": "4.6.x"
  }
}

# Install them
$ esy 

Install the VSCode extension

https://marketplace.visualstudio.com/items?itemName=ocamllabs.ocaml-platform

Enable esy as sandbox

CMD + P > "OCaml: Select a Sandbox for this Workspace" > Choose "Esy"

Hope it helps, if you find any issue please go to the Discord: https://discord.gg/T6YxT5JCWX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment