aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2025-10-03 17:01:26 -0700
committerGravatar Tom Willemse2025-10-03 17:01:26 -0700
commite3d8d95c0340b25b5a006dc85de8de3ac86d8453 (patch)
tree3c33c25faf4fc4c6dfbfe61399c03975c2a6e83b
parent0acbfbc5dcbe87d4d98ddf7f2b60e2fe82826834 (diff)
downloademacs-config-e3d8d95c0340b25b5a006dc85de8de3ac86d8453.tar.gz
emacs-config-e3d8d95c0340b25b5a006dc85de8de3ac86d8453.zip
oni-web: Add imenu regexp expression
-rw-r--r--oni-web.el22
1 files changed, 21 insertions, 1 deletions
diff --git a/oni-web.el b/oni-web.el
index 1fec6bf..fccfbd5 100644
--- a/oni-web.el
+++ b/oni-web.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2025.0709.110108
+;; Version: 2025.1003.170118
;; Package-Requires: (web-mode oni-flycheck prettier-js)
;; This program is free software; you can redistribute it and/or modify
@@ -58,5 +58,25 @@
;;;###autoload
(add-to-list 'auto-mode-alist (cons (rx ".vue" eos) 'web-mode))
+(defun oni-web-set-imenu-expression ()
+ (setq-local imenu-create-index-function 'imenu-default-create-index-function
+ imenu-generic-expression
+ (list
+ (list
+ "Html"
+ (rx (or (seq "id=\"" (group-n 1 (one-or-more (not "\""))) "\"")
+ (seq "<h" (any (?1 . ?6)) (minimal-match (one-or-more (not ">"))) ">" (group-n 1 (minimal-match (one-or-more any))) "</h" (any (?1 . ?6)) ">")))
+ 1)
+ (list
+ "JavaScript"
+ (rx (seq bol (minimal-match (zero-or-more space))
+ (or (seq (optional "async ") (group-n 1 (minimal-match (one-or-more alnum))) "(" (minimal-match (zero-or-more (not ")"))) ")" (minimal-match (zero-or-more white)) "{")
+ (seq (minimal-match (group-n 1 (one-or-more alnum))) ":" (minimal-match (zero-or-more white)) (optional "function ") "(")
+ (seq (optional "export ") "function " (minimal-match (group-n 1 (one-or-more (any punct alnum)))) "(" (minimal-match (zero-or-more (not ")"))) ")" (minimal-match (zero-or-more space)) "{")
+ (seq (optional "export ") (optional "const ") (minimal-match (group-n 1 (one-or-more (any punct alnum)))) (minimal-match (zero-or-more space)) "=" (minimal-match (zero-or-more space)) (optional "async") (optional "function") (minimal-match (zero-or-more space)) "("))))
+ 1))))
+
+(add-hook 'web-mode-hook #'oni-web-set-imenu-expression)
+
(provide 'oni-web)
;;; oni-web.el ends here