DEV Community

Alain
Alain

Posted on

1

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.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more