]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve treesit settings for java-ts-mode (bug#73404, bug#76493)
authorJuri Linkov <juri@linkov.net>
Wed, 5 Mar 2025 17:47:31 +0000 (19:47 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 9 Mar 2025 07:05:45 +0000 (08:05 +0100)
* lisp/progmodes/java-ts-mode.el (java-ts-mode):
Add the 'list' thing to 'treesit-thing-settings'.
Set 'treesit-outline-predicate'.

(cherry picked from commit 70d0da3fe0b73f7a8757a155feb5efa52e2a1c3a)

lisp/progmodes/java-ts-mode.el

index b9e605e4f9fac86ba734f0f0ed3444d271ec1ab9..961af5e12028412285299c0e41f8b4ac24f018a0 100644 (file)
@@ -423,6 +423,26 @@ Return nil if there is no name or if NODE is not a defun node."
                                   "_type"
                                   "true"
                                   "false")))
+                   (list ,(rx bos (or "inferred_parameters"
+                                      "parenthesized_expression"
+                                      "argument_list"
+                                      "type_arguments"
+                                      "switch_block"
+                                      "record_pattern_body"
+                                      "block"
+                                      "resource_specification"
+                                      "annotation_argument_list"
+                                      "element_value_array_initializer"
+                                      "module_body"
+                                      "enum_body"
+                                      "type_parameters"
+                                      "class_body"
+                                      "constructor_body"
+                                      "annotation_type_body"
+                                      "interface_body"
+                                      "array_initializer"
+                                      "formal_parameters")
+                              eos))
                    (sentence ,(rx (or "statement"
                                       "local_variable_declaration"
                                       "field_declaration"
@@ -458,6 +478,14 @@ Return nil if there is no name or if NODE is not a defun node."
                 ("Interface" "\\`interface_declaration\\'" nil nil)
                 ("Enum" "\\`record_declaration\\'" nil nil)
                 ("Method" "\\`method_declaration\\'" nil nil)))
+  ;; Outline minor mode
+  (setq-local treesit-outline-predicate
+              (rx bos (or "class_declaration"
+                          "interface_declaration"
+                          "method_declaration"
+                          "constructor_declaration")
+                  eos))
+
   (treesit-major-mode-setup))
 
 (derived-mode-add-parents 'java-ts-mode '(java-mode))