(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)
"/"))))))
(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."
(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."