File tree 2 files changed +32
-1
lines changed
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -662,7 +662,8 @@ Groups 6-9 can be used in any of argument regexps."
662
662
" Default expressions to highlight in Lua mode." )
663
663
664
664
(defvar lua-imenu-generic-expression
665
- `((nil ,(lua-rx (or bol " ;" ) ws (opt (seq (symbol " local" ) ws)) lua-funcheader) 1 ))
665
+ `((" Requires" ,(lua-rx (or bol " ;" ) ws (opt (seq (symbol " local" ) ws)) (group-n 1 lua-name) ws " =" ws (symbol " require" )) 1 )
666
+ (nil ,(lua-rx (or bol " ;" ) ws (opt (seq (symbol " local" ) ws)) lua-funcheader) 1 ))
666
667
" Imenu generic expression for lua-mode. See `imenu-generic-expression' ." )
667
668
668
669
(defvar lua-sexp-alist '((" then" . " end" )
Original file line number Diff line number Diff line change 3
3
default-directory))
4
4
" utils.el" ) nil 'nomessage 'nosuffix )
5
5
6
+ (require 'imenu )
7
+
6
8
(describe " lua-forward-sexp"
7
9
(it " properly scans through curly braces"
8
10
(with-lua-buffer
77
79
(it " is derived from prog-mode"
78
80
(with-lua-buffer
79
81
(expect (derived-mode-p 'prog-mode )))))
82
+
83
+ (describe " imenu integration"
84
+ (it " indexes functions"
85
+ (with-lua-buffer
86
+ (insert " \
87
+ function foo()
88
+ function bar() end
89
+ local function baz() end
90
+ qux = function() end
91
+ local quux = function() end
92
+ end
93
+ " )
94
+ (expect (mapcar 'car (funcall imenu-create-index-function))
95
+ :to-equal '(" foo" " bar" " baz" " qux" " quux" ))))
96
+
97
+ (it " indexes require statements"
98
+ (with-lua-buffer
99
+ (insert " \
100
+ foo = require (\" foo\" )
101
+ local bar = require (\" bar\" )
102
+ " )
103
+ (expect (mapcar (lambda (item ) (cons (car item)
104
+ (if (listp (cdr item))
105
+ (mapcar 'car (cdr item))
106
+ -1 )))
107
+ (funcall imenu-create-index-function))
108
+ :to-equal '((" Requires" . (" foo" " bar" )))))))
109
+
You can’t perform that action at this time.
0 commit comments