From f6e6d6c7302da1d4d18a9284576471b47da4b6af Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sat, 1 Jul 2023 22:48:07 +0100 Subject: [PATCH] Eglot: bail out of eglot-imenu if no server capability (bug#64274) * lisp/progmodes/eglot.el (eglot-imenu): Bail out if no capability. --- lisp/progmodes/eglot.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 94ca5c94245..d9a835ae844 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3350,9 +3350,11 @@ for which LSP on-type-formatting should be requested." (mapcar (lambda (c) (apply #'dfs c)) children)))))) (mapcar (lambda (s) (apply #'dfs s)) res))) -(defun eglot-imenu () +(cl-defun eglot-imenu () "Eglot's `imenu-create-index-function'. Returns a list as described in docstring of `imenu--index-alist'." + (unless (eglot--server-capable :textDocument/documentSymbol) + (cl-return-from eglot-imenu)) (let* ((res (eglot--request (eglot--current-server-or-lose) :textDocument/documentSymbol `(:textDocument -- 2.39.2