Skip to content

Xref backend without tunneling#72

Closed
xvw wants to merge 11 commits into
mainfrom
xref-backend-without-tunneling
Closed

Xref backend without tunneling#72
xvw wants to merge 11 commits into
mainfrom
xref-backend-without-tunneling

Conversation

@xvw

@xvw xvw commented Nov 5, 2025

Copy link
Copy Markdown
Member

This PR make two things:

  • Add ocaml-eglot-locate with a behaviour similar to merlin-locate (based on preference)
  • Remove, when it is possible, usage of merlinCallCompatible for finding definition/declaration

@xvw xvw requested a review from catern November 5, 2025 15:33
@xvw xvw force-pushed the xref-backend-without-tunneling branch 2 times, most recently from af3d3ce to 774c815 Compare November 5, 2025 15:46
Comment thread ocaml-eglot-xref.el Outdated
Comment thread ocaml-eglot-xref.el Outdated
Comment thread ocaml-eglot-xref.el Outdated
Comment thread ocaml-eglot-util.el Outdated
Comment thread ocaml-eglot-req.el Outdated
@xvw xvw force-pushed the xref-backend-without-tunneling branch 2 times, most recently from b799285 to 264a6ea Compare November 5, 2025 15:51
Comment thread ocaml-eglot-xref.el Outdated
Comment thread ocaml-eglot-xref.el Outdated
Comment thread ocaml-eglot-xref.el Outdated
Comment thread ocaml-eglot-xref.el Outdated
Comment thread ocaml-eglot-xref.el Outdated
Comment thread ocaml-eglot-xref.el
@xvw xvw force-pushed the xref-backend-without-tunneling branch from ced74d3 to 9658aac Compare January 19, 2026 12:00
Comment thread ocaml-eglot-xref.el Outdated
Comment thread ocaml-eglot-xref.el Outdated
@xvw xvw force-pushed the xref-backend-without-tunneling branch from 1f25499 to a9228ce Compare January 19, 2026 13:32
Comment thread ocaml-eglot-xref.el Outdated
Comment thread ocaml-eglot-xref.el Outdated
@xvw xvw requested a review from catern January 19, 2026 17:11
@xvw xvw force-pushed the xref-backend-without-tunneling branch from 0accb84 to f6cef25 Compare January 21, 2026 12:00
Comment thread ocaml-eglot-xref.el Outdated
Comment thread ocaml-eglot-xref.el
;; The LSP doesn't support jumping to definition of an arbitrary identifier,
;; so we have to fallback on ocamllsp/locate.
(if-let* ((locate-result
(ocaml-eglot-req--send

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try using eglot--lsp-xrefs-for-method for this case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try this implementation:

(cl-defmethod xref-backend-definitions ((_backend (eql ocaml-eglot-xref)) symbol)
  "Extension of `xref-backend-definitions' for SYMBOL."
  (if-let* ((pt (get-text-property 0 'eglot--lsp-workspaceSymbol symbol)))
      ;; SYMBOL is from `xref-backend-identifier-at-point',
      ;; since if it was read from the minibuffer its text
      ;; properties would have been stripped
      ;; (see `minibuffer-allow-text-properties').  Just pass
      ;; position and Merlin will figure out everything from that.
      (eglot--lsp-xrefs-for-method
       (if (eq ocaml-eglot-locate-preference 'mli)
           :textDocument/declaration
         :textDocument/definition))
    ;; The LSP doesn't support jumping to definition of an arbitrary identifier,
    ;; so we have to fallback on ocamllsp/locate.
    (eglot--lsp-xrefs-for-method
     :ocamllsp/locate
     :extra-params (list :kind (if (eq ocaml-eglot-locate-preference 'mli)
                                   "declaration"
                                 "definition")
                         :prefix (string-remove-suffix "." symbol))
     :capability :experimental/ocamllsp/handleLocate)))

But it leads to the following issue: [eglot] Unsupported or ignored LSP capability 'ocamllsp/handleLocate' and if I avoid capability it try to use locateProvider so it seems blocked.

@xvw xvw force-pushed the xref-backend-without-tunneling branch from f6cef25 to 3fd16c3 Compare January 26, 2026 12:03
@xvw xvw closed this Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants