Does BER MetaOCaml work with OCaml's LSP? (VSCode etc.)

My dune build --watch succeeds, but ocamllsp complains once the code starts using MetaOCaml’s constructs. E.g.: Undbound value >., and it loses track of where a function body ends (annotating local definitions as toplevel and warning of unused arguments).

As you discovered, the answer is “no”.

The LSP server depends on Merlin for typechecking and Merlin itself vendors a modified copy of the upstream OCaml typechecker. To support MetaOCaml, Merlin should be modified to include MetaOCaml’s typer modifications.

My own take is that eventually MetaOCaml will become part of the upstream compiler (but probably not in the short term), at which point Merlin (and OCaml-LSP) will automatically pick up support for it.

Cheers,
Nicolas

1 Like

In the meantime, I moved away from MetaOCaml. But if anyone is actively using MetaOCaml, I suggest using a PPX extension with [%c ...], [%e ...]. This is really concise and works much better with editor integrations.

1 Like