From ac0e78e5329d092166d170bfd849129fad44046e Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 5 Mar 2025 19:47:31 +0200 Subject: [PATCH] Improve treesit settings for java-ts-mode (bug#73404, bug#76493) * 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 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index b9e605e4f9f..961af5e1202 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -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)) -- 2.39.5