Limit recursion level for tree-sitter imenu functions

Generating imenu index doesn't require going down to the bottom of the
tree (defun's are usually top-level).  Add limit so we don't go too
far down on very large buffers.

* lisp/progmodes/c-ts-mode.el (c-ts-mode--imenu)
* lisp/progmodes/java-ts-mode.el (java-ts-mode--imenu)
* lisp/progmodes/js.el (js--treesit-imenu)
* lisp/progmodes/json-ts-mode.el (json-ts-mode--imenu)
* lisp/progmodes/python.el (python-imenu-treesit-create-index)
* lisp/textmodes/css-mode.el (css--treesit-imenu): Add limit to
treesit-induce-sparse-tree.
This commit is contained in:
Yuan Fu
2022-11-20 16:56:33 -08:00
parent 625ea08652
commit 32870d2f20
6 changed files with 17 additions and 14 deletions

View File

@@ -5492,7 +5492,8 @@ Similar to `python-imenu-create-index' but use tree-sitter."
(rx (seq bol
(or "function" "class")
"_definition"
eol)))))
eol))
nil 1000)))
(python--imenu-treesit-create-index-1 tree)))
(defun python-imenu-treesit-create-flat-index ()