dune icon indicating copy to clipboard operation
dune copied to clipboard

pkg: provide Merlin/LSP configuration for navigating packages sources

Open voodoos opened this issue 2 months ago • 0 comments

Having OCaml editor support when navigating installed libraries' sources has been a recurring request from the community for years. There is no doubt that this request will be made again, and it's possible that having Dune Pkg Management could finally be the key to answer it.

The current situation: you navigate your project's code and jump to the definition of some value that comes from an external library. This can be useful to better understand an undocumented API or to estimate the algorithmic complexity of a function for example. But once you reached the source for that external value, Merlin and LSP will run in a very degraded mode, because they don't have the proper configuration and artifacts available.

This happens because the Merlin configuration generated by Dune (or another build system) are not installed along with the artifacts and cmi. Additionally, it wouldn't be enough to install these files, since the topology of installed artifacts is often different from the actual build directory organization.

But now that Dune handles package itself, it looks like we should have all the information we need to actually provide this behavior, in a similar way as if the dependencies were vendored in the project.

I don't know of it's feasibility or drawbacks, but I think a naive approach would be to have the _build folder of packages linked inside their _build/_private/.pkg/xxxxx/source folder (and slightly modify the generated confs to point Merlin to these source files instead of the ones in the target directory).

voodoos avatar Dec 04 '25 09:12 voodoos