DEV Community

Alain
Alain

Posted on

Editor Support for ReasonML in VSCode with Melange

I have been trying for a long while now to work with ReasonML files in VSCode and get some syntax highlighting. This has been a problem since ReasonML on the frontend has moved on to Rescript. The solution would be using Melange but I could not get the editor highlighting to work. I have a bunch of old ReasonML projects that I still refer to so losing the editor support has been less than ideal. The code still works but you are stuck relying on the terminal output for errors.

I finally got it to work with the help of @zecklar on the ReasonML Discord forum.

Here is the solution that works.

  1. Install OCaml plugin https://marketplace.visualstudio.com/items?itemName=ocamllabs.ocaml-platform
  2. Build your project esy build
  3. Launch VSCode in your esy dev environment esy code .
  4. On the lefthand side, click OCaml extension icon
  5. Click "Select sandbox"
  6. Select "Custom" from the dropdown
  7. Pass the flag, the input box should contain $prog $args --fallback-read-dot-merlin
  8. Voila, at least typehints/navigation etc seem to work

You can try it with this repo.

This isnt working for rescript yet but I will update you if I figure it out.

Many thank, @zecklar.

Top comments (0)