aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/lua-ts-mode.el43
-rw-r--r--lisp/speedbar.el2
2 files changed, 37 insertions, 8 deletions
diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el
index 80cf119f75c..2193779b759 100644
--- a/lisp/progmodes/lua-ts-mode.el
+++ b/lisp/progmodes/lua-ts-mode.el
@@ -443,6 +443,33 @@ Return nil if there is no name or if NODE is not a defun node."
443 (and (treesit-search-subtree node "function_definition" nil nil 1) 443 (and (treesit-search-subtree node "function_definition" nil nil 1)
444 (treesit-node-text child t)))))) 444 (treesit-node-text child t))))))
445 445
446(defun lua-ts--named-function-p (node)
447 "Matches if NODE is a named function."
448 (let ((type (treesit-node-type node)))
449 (or (equal "function_declaration" type)
450 (and (equal "field" type)
451 (equal "function_definition"
452 (treesit-node-type
453 (treesit-node-child-by-field-name
454 node "value")))
455 (treesit-node-child-by-field-name node "name")))))
456
457(defun lua-ts--require-name-function (node)
458 "Return name of NODE to use for requires in imenu."
459 (when-let* (((lua-ts--require-p node))
460 (parent (treesit-node-parent node))
461 (parent-type (treesit-node-type parent)))
462 (if (equal "expression_list" parent-type)
463 (let* ((g-parent (treesit-node-parent parent))
464 (name (treesit-node-child-by-field-name g-parent "name")))
465 (treesit-node-text name t))
466 (treesit-node-text (treesit-search-subtree node "string_content") t))))
467
468(defun lua-ts--require-p (node)
469 "Matches if NODE is a require statement."
470 (let ((name (treesit-node-child-by-field-name node "name")))
471 (equal "require" (treesit-node-text name t))))
472
446(defvar-local lua-ts--flymake-process nil) 473(defvar-local lua-ts--flymake-process nil)
447 474
448(defun lua-ts-flymake-luacheck (report-fn &rest _args) 475(defun lua-ts-flymake-luacheck (report-fn &rest _args)
@@ -692,13 +719,15 @@ Calls REPORT-FN directly."
692 719
693 ;; Imenu. 720 ;; Imenu.
694 (setq-local treesit-simple-imenu-settings 721 (setq-local treesit-simple-imenu-settings
695 `(("Variable" ,(rx bos "variable_declaration" eos) nil nil) 722 `(("Requires"
696 ("Function" ,(rx bos 723 "\\`function_call\\'"
697 (or "function_declaration" 724 lua-ts--require-p
698 "function_definition" 725 lua-ts--require-name-function)
699 "field") 726 ("Variables" "\\`variable_declaration\\'" nil nil)
700 eos) 727 (nil
701 nil nil))) 728 "\\`\\(?:f\\(?:ield\\|unction_declaration\\)\\)\\'"
729 lua-ts--named-function-p
730 nil)))
702 731
703 ;; Which-function. 732 ;; Which-function.
704 (setq-local which-func-functions (treesit-defun-at-point)) 733 (setq-local which-func-functions (treesit-defun-at-point))
diff --git a/lisp/speedbar.el b/lisp/speedbar.el
index 67d4e8c4df1..51c5962cb66 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el
@@ -631,7 +631,7 @@ function `speedbar-extension-list-to-regex'.")
631 (append '(".[ch]\\(\\+\\+\\|pp\\|c\\|h\\|xx\\)?" ".tex\\(i\\(nfo\\)?\\)?" 631 (append '(".[ch]\\(\\+\\+\\|pp\\|c\\|h\\|xx\\)?" ".tex\\(i\\(nfo\\)?\\)?"
632 ".el" ".emacs" ".l" ".lsp" ".p" ".java" ".js" ".f\\(90\\|77\\|or\\)?") 632 ".el" ".emacs" ".l" ".lsp" ".p" ".java" ".js" ".f\\(90\\|77\\|or\\)?")
633 (if speedbar-use-imenu-flag 633 (if speedbar-use-imenu-flag
634 '(".ad[abs]" ".p[lm]" ".tcl" ".m" ".scm" ".pm" ".py" ".g" 634 '(".ad[abs]" ".p[lm]" ".tcl" ".m" ".scm" ".pm" ".py" ".g" ".lua"
635 ;; html is not supported by default, but an imenu tags package 635 ;; html is not supported by default, but an imenu tags package
636 ;; is available. Also, html files are nice to be able to see. 636 ;; is available. Also, html files are nice to be able to see.
637 ".s?html" 637 ".s?html"