We don't want to match local_variable_declaration and others to hit on
beginning-of-defun. The fix is just to make the regexp a bit more
granular.
* lisp/progmodes/java-ts-mode.el (java-ts-mode): Use regexp-opt to
distinguish more granularly.
(append "{}():;," electric-indent-chars))
;; Navigation.
- (setq-local treesit-defun-type-regexp "declaration")
+ (setq-local treesit-defun-type-regexp
+ (regexp-opt '("method_declaration"
+ "class_declaration"
+ "record_declaration"
+ "interface_declaration"
+ "enum_declaration"
+ "import_declaration"
+ "package_declaration"
+ "module_declaration")))
;; Font-lock.
(setq-local treesit-font-lock-settings java-ts-mode--font-lock-settings)