Dune project: get list of (module_name, file_name, line_number)

I have a project that builds under dune. Is there a way to have it dump a list of:

(full module_name , file_name, line_number)

The XY problem is:

I’m in neovim. I want to hit “goto module”, have it provide me a list of the full module_name in telescope, so I can interactively select the one I want, then have it jump to the right (file_name, line_number)

lsp has a command go to symbol in workspace, I don’t know under what name it is exposed in neovim. But I believe that it would do what you want.

The main problem is that it tends to be slow on big projects.

Hmm. I’m wondering (perhaps naively) if there is a way to get dune build -w to dump out this information. I’m okay if the information is “outdated” in that it is only refreshed on every successful build.

Unfortunately I don’t think that what you want exists. dune describe workspace has a good number of information but not the granularity you are looking for.

You could build something based on the outline feature of merlin. The easiest way to try it is cat your_file.ml | ocamlmerlin single outline.

The documentation: merlin/PROTOCOL.md at master · ocaml/merlin · GitHub

There’s also ocp-index. But I’m not sure how it would get started with that one.

1 Like