Skip to content

Commit

Permalink
Per #131, #314: Be more conservative with the LSP identifier guess
Browse files Browse the repository at this point in the history
If the user is not requesting a prompt, opt for the safer approach
which is to get the location from textDocument/definition, not from
workspace/symbol.  Because of things like function overloading, the
latter is not always successful in finding exactly the definition of
the thing one is invoking M-. on.

This requires using an xref-internal symbol, which is kind of
unfortunate.

* eglot.el (xref-backend-identifier-at-point): Rework.

#131: joaotavora/eglot#131
#314: joaotavora/eglot#314
  • Loading branch information
joaotavora committed Jul 15, 2022
1 parent 0263883 commit c98cafb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lisp/progmodes/eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -2458,10 +2458,11 @@ If BUFFER, switch to it before."

(cl-defmethod xref-backend-identifier-at-point ((_backend (eql eglot)))
(let ((attempt
(puthash :default
(ignore-errors
(eglot--workspace-symbols (symbol-name (symbol-at-point))))
eglot--workspace-symbols-cache)))
(and (xref--prompt-p this-command)
(puthash :default
(ignore-errors
(eglot--workspace-symbols (symbol-name (symbol-at-point))))
eglot--workspace-symbols-cache))))
(if attempt (car attempt) "LSP identifier at point")))

(defvar eglot--lsp-xref-refs nil
Expand Down

0 comments on commit c98cafb

Please sign in to comment.