emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eglot 194b178ef4 11/33: Close #712: Add support for Loc


From: Stefan Kangas
Subject: [elpa] externals/eglot 194b178ef4 11/33: Close #712: Add support for LocationLink
Date: Sat, 8 Jan 2022 12:30:49 -0500 (EST)

branch: externals/eglot
commit 194b178ef41ccd3d937983f3829d44a546bb24d6
Author: Brian Leung <leungbk@mailfence.com>
Commit: João Távora <joaotavora@gmail.com>

    Close #712: Add support for LocationLink
    
    Fix #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
---
 eglot.el | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/eglot.el b/eglot.el
index 83bd1024a0..0f367fd220 100644
--- a/eglot.el
+++ b/eglot.el
@@ -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))
@@ -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
@@ -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 )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]