tag: 1.2
commit da4cd2a37ea3619b02e9c6ae7b7a68ec558d0506
Author: MichaĆ Krzywkowski <[email protected]>
Commit: mkcms <[email protected]>
Make imenu hierarchical
* eglot.el (eglot-imenu): Use :containerName to build a nested imenu
index alist.
---
eglot.el | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/eglot.el b/eglot.el
index f11a14e..22f509b 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1670,20 +1670,29 @@ If SKIP-SIGNATURE, don't try to send
textDocument/signatureHelp."
(jsonrpc-lambda
(&key name kind location containerName _deprecated)
(cons (propertize
- (concat
- (and (stringp containerName)
- (not (string-empty-p containerName))
- (concat containerName "::"))
- name)
+ name
:kind (alist-get kind eglot--symbol-kind-names
- "(Unknown)"))
+ "Unknown")
+ :containerName (and (stringp containerName)
+ (not (string-empty-p containerName))
+ containerName))
(eglot--lsp-position-to-point
(plist-get (plist-get location :range) :start))))
(jsonrpc-request (eglot--current-server-or-lose)
:textDocument/documentSymbol
`(:textDocument
,(eglot--TextDocumentIdentifier))))))
- (seq-group-by (lambda (e) (get-text-property 0 :kind (car e)))
- entries))
+ (mapcar
+ (pcase-lambda (`(,kind . ,syms))
+ (let ((syms-by-scope (seq-group-by
+ (lambda (e)
+ (get-text-property 0 :containerName (car
e)))
+ syms)))
+ (cons kind (cl-loop for (scope . elems) in syms-by-scope
+ append (if scope
+ (list (cons scope elems))
+ elems)))))
+ (seq-group-by (lambda (e) (get-text-property 0 :kind (car e)))
+ entries)))
(funcall oldfun)))
(defun eglot--apply-text-edits (edits &optional version)