diff options
| -rw-r--r-- | oni-web.el | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -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 |
