imenu-extra

Homepage: https://github.com/redguardtoo/imenu-extra

Updated:

Summary

Add extra items into existing imenu items

Commentary

Add extra items into existing imenu items generated by major/minor modes.
 For example, extra items could be appended into existing imenu items
 generated by lsp-mode and js2-mode.

 Set up,
   At the end of minor/major mode hook, call `imenu-extra-auto-setup' which has
   one parameter "patterns".
   Patterns should be an alist of the same form as `imenu-generic-expression'.
   For example, insert below code to `js2-mode-hook' to extract unit test
   cases from javascript code.

(add-hook 'js2-mode-hook
          (lambda ()
            ;; original js2-mode setup ...

            ;; at the end of mode hook
            (require 'imenu-extra)
            (imenu-extra-auto-setup '(("tdd.it" "^[ \t]*it('\\([^']+\\)" 1)
                                      ("tdd.desc" "^[ \t]*describe('\\([^']+\\)" 1))))
Tips:
  - Set `imenu-extra-process-item-function' to process extra imenu items

Usage,
  Use imenu as usual.

Dependencies