dune icon indicating copy to clipboard operation
dune copied to clipboard

Jump to definition inside installed libraries

Open ddickstein opened this issue 3 years ago • 5 comments

A while ago I discussed jumping to definition inside installed libraries, which would have required installing .merlin files alongside the libraries (https://github.com/ocaml/merlin/issues/863#issuecomment-428142595). Now that this is no longer a requirement since dune and Merlin can communicate directly without .merlin files, can this feature request be revisited? It seems the work here is on dune's side.

ddickstein avatar Nov 07 '22 04:11 ddickstein

@voodoos Could you confirm what rgrinberg wrote on discuss will work:

When merlin queries dune for the .merlin config, dune should be able to generation information that makes it possible to navigate through installed projects. I just need to confirm this is possible with Ulysse - the main developer of merlin/dune integration.

Alizter avatar Mar 21 '25 15:03 Alizter

What dune ocaml-merlin does right now is simply to check if a configuration was generated by Dune for the requested module and print that configuration to stdout. These configuration files are not installed so that doesn't work for installed modules.

Having dune ocaml-merlin fabricate a configuration in that case seems a sensible thing to do. However this will only be possible if enough information is installed along with the library files. Looking at the dune-package files that contain some information about the libraries, there is indeed some fields missin. For example, the flags field of the libraries stanza is missing which means that merlin won't be able to correctly type some modules (missing a -open ... flag for example). I also expect preprocessing flags to be missing. These flags might be retrievable from the cmt files, but that sounds very hackish.

I think it might be relatively simple to use the information in the dune-package files to provide some sort of support for navigation in the installed world, by feeding Merlin the path to build artifacts. However, correct behavior for every library is probably not achievable with the currently installed artifacts.

voodoos avatar Mar 21 '25 16:03 voodoos

What are the blockers to installing the artifacts necessary for correct behavior in every installed library in a non-hacky way? If the concern is disk space I’d certainly be willing to pay that cost - if it were gated by a flag I’d happily pass it.

On Fri, Mar 21, 2025 at 12:30 PM Ulysse @.***> wrote:

What dune ocaml-merlin does right now is simply to check if a configuration was generated by Dune for the requested module and print that configuration to stdout. These configuration files are not installed so that doesn't work for installed modules.

Having dune ocaml-merlin fabricate a configuration in that case seems a sensible thing to do. However this will only be possible if enough information is installed along with the library files. Looking at the dune-package files that contain some information about the libraries, there is indeed some missing information. For example, the flags field of the libraries stanza is missing which means that merlin won't be able to correctly type some modules (missing a -open ... flag for example). I also expect preprocessing flags to be missing. These flags might be retrievable from the cmt files, but that sounds very hackish.

I think it might be relatively simple to use the information in the dune-package files to provide some sort of support for navigation in the installed world, by feeding Merlin the path to build artifacts. However, correct behavior for every library is probably not achievable with the currently installed artifacts.

— Reply to this email directly, view it on GitHub https://github.com/ocaml/dune/issues/6397#issuecomment-2743881809, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGD5T2YGOKPZEXL6HJKBVD2VQ5B7AVCNFSM6AAAAABZQJQUGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONBTHA4DCOBQHE . You are receiving this because you authored the thread.Message ID: @.***> [image: voodoos]voodoos left a comment (ocaml/dune#6397) https://github.com/ocaml/dune/issues/6397#issuecomment-2743881809

What dune ocaml-merlin does right now is simply to check if a configuration was generated by Dune for the requested module and print that configuration to stdout. These configuration files are not installed so that doesn't work for installed modules.

Having dune ocaml-merlin fabricate a configuration in that case seems a sensible thing to do. However this will only be possible if enough information is installed along with the library files. Looking at the dune-package files that contain some information about the libraries, there is indeed some missing information. For example, the flags field of the libraries stanza is missing which means that merlin won't be able to correctly type some modules (missing a -open ... flag for example). I also expect preprocessing flags to be missing. These flags might be retrievable from the cmt files, but that sounds very hackish.

I think it might be relatively simple to use the information in the dune-package files to provide some sort of support for navigation in the installed world, by feeding Merlin the path to build artifacts. However, correct behavior for every library is probably not achievable with the currently installed artifacts.

— Reply to this email directly, view it on GitHub https://github.com/ocaml/dune/issues/6397#issuecomment-2743881809, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGD5T2YGOKPZEXL6HJKBVD2VQ5B7AVCNFSM6AAAAABZQJQUGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONBTHA4DCOBQHE . You are receiving this because you authored the thread.Message ID: @.***>

ddickstein avatar Mar 21 '25 17:03 ddickstein

Another solution is to perhaps take advantage of package management. When dune builds packages itself, it could make sure that merlin works everywhere as intended.

Alizter avatar Mar 21 '25 17:03 Alizter

Another solution is to perhaps take advantage of package management. When dune builds packages itself, it could make sure that merlin works everywhere as intended.

Yes, Dune Pkg Management should "solve" that issue since every package is built in the local project.

voodoos avatar Mar 21 '25 17:03 voodoos