Skip to content

Commit

Permalink
Close joaotavora/eglot#712: Add support for LocationLink
Browse files Browse the repository at this point in the history
Fix joaotavora/eglot#711.

LocationLink was added in version 3.14 of the protocol and is
sometimes used in lieu of Location for definition- and
reference-related requests.

* eglot.el (eglot--lsp-interface-alist): Update with LocationLink.
(eglot-client-capabilities): Advertise
textDocument.{definition,declaration,implementation,typeDefinition}.linkSupport.
(eglot--lsp-xrefs-for-method): Accept LocationLinks.

Co-authored-by: João Távora <joaotavora@gmail.com
  • Loading branch information
leungbk authored and joaotavora committed Jul 21, 2021
1 parent 50ba400 commit a5f7b04
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions lisp/progmodes/eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ let the buffer grow forever."
(Hover (:contents) (:range))
(InitializeResult (:capabilities) (:serverInfo))
(Location (:uri :range))
(LocationLink (:targetUri :targetRange :targetSelectionRange) (:originSelectionRange))
(LogMessageParams (:type :message))
(MarkupContent (:kind :value))
(ParameterInformation (:label) (:documentation))
Expand Down Expand Up @@ -639,10 +640,14 @@ treated as in `eglot-dbind'."
(:labelOffsetSupport t)
:activeParameterSupport t))
:references `(:dynamicRegistration :json-false)
:definition `(:dynamicRegistration :json-false)
:declaration `(:dynamicRegistration :json-false)
:implementation `(:dynamicRegistration :json-false)
:typeDefinition `(:dynamicRegistration :json-false)
:definition (list :dynamicRegistration :json-false
:linkSupport t)
:declaration (list :dynamicRegistration :json-false
:linkSupport t)
:implementation (list :dynamicRegistration :json-false
:linkSupport t)
:typeDefinition (list :dynamicRegistration :json-false
:linkSupport t)
:documentSymbol (list
:dynamicRegistration :json-false
:hierarchicalDocumentSymbolSupport t
Expand Down Expand Up @@ -2186,9 +2191,15 @@ Try to visit the target file for a richer summary line."
method (append (eglot--TextDocumentPositionParams) extra-params))))
(eglot--collecting-xrefs (collect)
(mapc
(eglot--lambda ((Location) uri range)
(collect (eglot--xref-make-match (symbol-name (symbol-at-point))
uri range)))
(lambda (loc-or-loc-link)
(let ((sym-name (symbol-name (symbol-at-point))))
(eglot--dcase loc-or-loc-link
(((LocationLink) targetUri targetSelectionRange)
(collect (eglot--xref-make-match sym-name
targetUri targetSelectionRange)))
(((Location) uri range)
(collect (eglot--xref-make-match sym-name
uri range))))))
(if (vectorp response) response (and response (list response)))))))

(cl-defun eglot--lsp-xref-helper (method &key extra-params capability )
Expand Down

0 comments on commit a5f7b04

Please sign in to comment.