0

I am trying to explore the project: https://github.com/kupl/VeriSmart-public. I am trying to use the go-to-definition feature of VS code but it is not working even with the offical Ocaml extension installed.

I've installed opam and used switch ocaml 4.10.0 and can succesfully build the repository following the build script (which is simply a ocamlbuild command). Moreover, I've tried almost all the relative ocaml extensions in VS code (even deprecated).

I think the problem might result from the fact that the codes are written for ocamlbuild instead of dune. So is there any way to use the go-to-definition for the repository on VS code?

1 Answers1

0

Dune has built-in support for generating configuration files that Merlin can consume to know how to work with your projects (where to find build artifacts, and which dependencies to load to make sense of the types in your code). If you are using another build system, you can write a .merlin file by hand.

See the Merlin documentation on .merlin files. It is very easy. Typically the following may be enough:

# where to find the build artifacts
B _build/**

# list your dependencies here (ocamlfind package names)
PKG unix containers cmdliner 
gasche
  • 31,259
  • 3
  • 78
  • 100
  • Thanks for the reply! I've tried to write merlin files like 'S src/**' 'B _build/**' and 'PKG ', yet it won't activate the go-to-definition funtion (of the ocaml platform extention). Is there any merlin-related VSC extention? (I tried to search for it with keywords like merlin/ocaml yet the result seemed not so promising) – GreenieQwQ Mar 13 '23 at 04:55
  • You may need to enable the `-bin-annot` option if it is not already enabled by default by the ocamlbuild configuration. Maybe try to change your ocamlbuild invocation to add `-cflag -bin-annot`. – gasche Mar 14 '23 at 05:43
  • Thanks! I've tried with the option yet it still won't work for VSC (plus the ocaml platform extention) and sorry for the late reply XD. – GreenieQwQ Mar 20 '23 at 15:06
  • I just tried with `B _build` as the unique content of `.merlin` file, and it seems to work fine with just Emacs+Merlin. (I don't actually need `-bin-annot` for go-to-definition to work, apparently, even across modules.) The issue may be related to vscode rather than Merlin itself, and I cannot help there, apologies. – gasche Mar 21 '23 at 20:11