Jump-to-definition, opam libraries, and "No config found for file _opam/lib/…" #1062
Replies: 1 comment
-
Jumping to definitions in installed libraries in OCaml is a long standing pain point. This is a problem that does not exist in Rust for instance. You can always jump to definition in crates which are dependencies. This gives you full visibility into the code your project will run. There are some discussions about this on discuss.ocaml.org that can help you for OCaml. Here is one of them: "Merlin: Goto definition inside installed libraries " Even though that discussion is about Merlin, it is applicable to your question because ocaml-lsp uses merlin as a backend for its OCaml "intelligence". TL;DR the best approach that I know of currently (which works in most of the cases) is to "vendor" your dependencies. (Look up dune vendoring to learn more). So, you would NOT install the dependencies in your opam switch, rather the source code of your dependencies would be embedded with your project source code (usually under the There is a tool that does this for you. Its called Sorry if this sounds too intricate. Its actually not. Here is an example: (I used dream as an example in the link above, the project does some complicated things with dependencies already so can be a bit tricky to use opam monorepo with. Try it with some other project. This works properly in even recent versions of OCaml 4.14.1, 5.0 etc. so don't worry about the comment being outdated). For completeness I would like to add that |
Beta Was this translation helpful? Give feedback.
-
One consistent pain when working with the OCaml Platform is using jump-to-definition to browse code that's in opam dependencies:
Is there any workaround to "link up" the source files that jump-to-definition hits, and the actual build-products from Dune? Some way to make the browsing/spelunking experience better?
Beta Was this translation helpful? Give feedback.
All reactions