]> git.eshelyaron.com Git - emacs.git/commitdiff
Unbreak xref-find-definitions
authorJoão Távora <joaotavora@gmail.com>
Sun, 13 Oct 2019 21:32:52 +0000 (22:32 +0100)
committerJoão Távora <joaotavora@gmail.com>
Sun, 13 Oct 2019 21:32:52 +0000 (22:32 +0100)
* eglot-tests.el (basic-xref): New test.

* eglot.el (eglot--collecting-xrefs): Add an edebug spec.
(eglot--lsp-xrefs-for-method): Actually collect xref.
(xref-backend-apropos): Fix indentation slightly.

GitHub-reference: fix https://github.com/joaotavora/eglot/issues/318

lisp/progmodes/eglot.el

index 9d5c546cefeed32d67af46129b776ee331f404a0..7b0e3e28a6d24798359a78bfc780d628b20d0d43 100644 (file)
@@ -1724,6 +1724,7 @@ Calls REPORT-FN maybe if server publishes diagnostics in time."
 
 (cl-defmacro eglot--collecting-xrefs ((collector) &rest body)
   "Sort and handle xrefs collected with COLLECTOR in BODY."
+  (declare (indent 1) (debug (sexp &rest form)))
   (let ((collected (cl-gensym "collected")))
     `(unwind-protect
          (let (,collected)
@@ -1786,13 +1787,13 @@ Try to visit the target file for a richer summary line."
                                             "/"))))))
     (eglot--error "Sorry, this server doesn't do %s" method))
   (eglot--collecting-xrefs (collect)
-   (mapc
-    (eglot--lambda ((Location) uri range)
-      (eglot--xref-make (symbol-at-point) uri range))
-    (jsonrpc-request
-     (eglot--current-server-or-lose) method (append
-                                             (eglot--TextDocumentPositionParams)
-                                             extra-params)))))
+    (mapc
+     (eglot--lambda ((Location) uri range)
+       (collect (eglot--xref-make (symbol-at-point) uri range)))
+     (jsonrpc-request
+      (eglot--current-server-or-lose) method (append
+                                              (eglot--TextDocumentPositionParams)
+                                              extra-params)))))
 
 (cl-defun eglot--lsp-xref-helper (method &key extra-params capability )
   "Helper for `eglot-find-declaration' & friends."
@@ -1829,13 +1830,13 @@ Try to visit the target file for a richer summary line."
 (cl-defmethod xref-backend-apropos ((_backend (eql eglot)) pattern)
   (when (eglot--server-capable :workspaceSymbolProvider)
     (eglot--collecting-xrefs (collect)
-     (mapc
-      (eglot--lambda ((SymbolInformation) name location)
-        (eglot--dbind ((Location) uri range) location
-          (collect (eglot--xref-make name uri range))))
-      (jsonrpc-request (eglot--current-server-or-lose)
-                       :workspace/symbol
-                       `(:query ,pattern))))))
+      (mapc
+       (eglot--lambda ((SymbolInformation) name location)
+         (eglot--dbind ((Location) uri range) location
+           (collect (eglot--xref-make name uri range))))
+       (jsonrpc-request (eglot--current-server-or-lose)
+                        :workspace/symbol
+                        `(:query ,pattern))))))
 
 (defun eglot-format-buffer ()
   "Format contents of current buffer."