Skip to content

Get project‐wide occurrences

Ulysse edited this page Jul 4, 2024 · 2 revisions

When using OCaml 5.2 and since the release of merlin-lib 5.1-502, Emacs and Vim clients for merlin, as well as LSP clients for ocaml-lsp-sever can return project-wide results when searching for the occurrences of an identifier. This new feature require an index to be built beforehand.

Indexation

As of today, the simplest way to build (and keep up to date) an index of your project is to use a recent version of Dune (>= 3.16.0) and build the alias @ocaml-index in watch mode:

dune build @ocaml-index --watch

After that, it is possible to query for project-wide occurrences using:

  • merlin-project-occurrences in emacs
  • MerlinOccurrencesProjectWide in vim
  • references in LSP-based plugins.

Usage example in visual studio code

Screen.Recording.2024-06-11.at.15.29.40.mov

More resources: