]> git.eshelyaron.com Git - emacs.git/commitdiff
Make imenu hierarchical
authorMichal Krzywkowski <k.michal@zoho.com>
Sun, 4 Nov 2018 15:34:58 +0000 (16:34 +0100)
committerMichal Krzywkowski <k.michal@zoho.com>
Wed, 7 Nov 2018 11:09:06 +0000 (12:09 +0100)
* eglot.el (eglot-imenu): Use :containerName to build a nested imenu
  index alist.

lisp/progmodes/eglot.el

index f11a14e11c5ecc021febf95cc84d48887d368d26..22f509b81b28bacb16dd2d65193d912ccf01bb64 100644 (file)
@@ -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)