Skip to content

Commit

Permalink
Merge pull request #19 from tarides/more-specific-commands-prerelease
Browse files Browse the repository at this point in the history
`ocaml-eglot-occurences` as an alias for `xref-find-references`
  • Loading branch information
xvw authored Jan 15, 2025
2 parents 137fe4c + 8c97a12 commit 51eb8cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added media/occurences.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions ocaml-eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
;;; Code:

(require 'flymake)
(require 'xref)
(require 'cl-lib)
(require 'ocaml-eglot-util)
(require 'ocaml-eglot-req)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 51eb8cb

Please sign in to comment.