diff --git a/README.md b/README.md index 300fee3..8b2e506 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,17 @@ provided: - `ocaml-eglot-find-type-definition-in-new-window` - `ocaml-eglot-find-type-definition-in-current-window` +### Find occurences + +`ocaml-eglot-occurences` returns all occurrences of the +identifier under the cursor. To find all occurrences in the entire +project, it requires an index. This index can be created by running +`dune build @ocaml-index --watch` when developing. Requires OCaml +`5.2` and Dune `3.16.0`. See the +[announcement](https://discuss.ocaml.org/t/ann-project-wide-occurrences-in-merlin-and-lsp/14847/1). + +![Occurences example](media/occurences.gif) + ### Infer Interface Used to infer the type of an interface file. If the buffer is not diff --git a/media/occurences.gif b/media/occurences.gif new file mode 100644 index 0000000..6516bed Binary files /dev/null and b/media/occurences.gif differ diff --git a/ocaml-eglot.el b/ocaml-eglot.el index 3d05848..4daf076 100644 --- a/ocaml-eglot.el +++ b/ocaml-eglot.el @@ -33,6 +33,7 @@ ;;; Code: (require 'flymake) +(require 'xref) (require 'cl-lib) (require 'ocaml-eglot-util) (require 'ocaml-eglot-req) @@ -464,6 +465,13 @@ If called repeatedly, increase the verbosity of the type shown." (interactive) (ocaml-eglot-req--destruct)) +;; Occurences + +(defun ocaml-eglot-occurences () + "Find all occurrences of the identifier under the cursor." + (interactive) + (call-interactively #'xref-find-references)) + ;;; Mode (defvar ocaml-eglot-map