aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2025-03-15 20:37:46 +0200
committerJuri Linkov2025-03-15 20:37:46 +0200
commitf3925732bc55be3d6d32d20b95f7a88926d4ebda (patch)
tree2ae4776570d8fd5339bd5654acc522f16fd7737c
parent4f4105e6227cdb00109efb683d96beb47fd894c4 (diff)
downloademacs-f3925732bc55be3d6d32d20b95f7a88926d4ebda.tar.gz
emacs-f3925732bc55be3d6d32d20b95f7a88926d4ebda.zip
Add the treesit 'list' thing to csharp/go/php/rust-ts-mode (bug#73404)
* lisp/progmodes/csharp-mode.el (csharp-ts-mode): Add the 'list' and 'sentence' things to 'treesit-thing-settings'. Set 'treesit-outline-predicate'. * lisp/progmodes/go-ts-mode.el (go-ts-mode): Add 'treesit-thing-settings' with the 'list' and 'sentence' things. * lisp/progmodes/php-ts-mode.el (php-ts-mode): Add the 'list' thing to 'treesit-thing-settings'. * lisp/progmodes/rust-ts-mode.el (rust-ts-mode): Add 'treesit-thing-settings' with the 'list' thing.
-rw-r--r--lisp/progmodes/csharp-mode.el74
-rw-r--r--lisp/progmodes/go-ts-mode.el19
-rw-r--r--lisp/progmodes/php-ts-mode.el16
-rw-r--r--lisp/progmodes/rust-ts-mode.el34
4 files changed, 143 insertions, 0 deletions
diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
index 6f3fd08089f..5e9b8d680eb 100644
--- a/lisp/progmodes/csharp-mode.el
+++ b/lisp/progmodes/csharp-mode.el
@@ -1067,6 +1067,68 @@ Key bindings:
1067 1067
1068 (setq-local treesit-thing-settings 1068 (setq-local treesit-thing-settings
1069 `((c-sharp 1069 `((c-sharp
1070 (list
1071 ,(rx bos (or "global_attribute"
1072 "attribute_argument_list"
1073 "attribute_list"
1074 "enum_member_declaration_list"
1075 "type_parameter_list"
1076 "declaration_list"
1077 "accessor_list"
1078 "bracketed_parameter_list"
1079 "parameter_list"
1080 "argument_list"
1081 "tuple_pattern"
1082 "block"
1083 "bracketed_argument_list"
1084 "type_argument_list"
1085 "array_rank_specifier"
1086 "function_pointer_type"
1087 "tuple_type"
1088 "_for_statement_conditions"
1089 "switch_body"
1090 "catch_declaration"
1091 "catch_filter_clause"
1092 "parenthesized_pattern"
1093 "list_pattern"
1094 "positional_pattern_clause"
1095 "property_pattern_clause"
1096 "parenthesized_variable_designation"
1097 "_switch_expression_body"
1098 "interpolated_string_expression"
1099 "interpolation"
1100 "parenthesized_expression"
1101 "_parenthesized_lvalue_expression"
1102 "anonymous_object_creation_expression"
1103 "initializer_expression"
1104 "_with_body"
1105 "tuple_expression"
1106 "preproc_parenthesized_expression")
1107 eos))
1108 (sentence
1109 ,(rx bos (or "extern_alias_directive"
1110 "using_directive"
1111 "file_scoped_namespace_declaration"
1112 "enum_declaration"
1113 "delegate_declaration"
1114 "_declaration_list_body"
1115 "field_declaration"
1116 "event_declaration"
1117 "event_field_declaration"
1118 "indexer_declaration"
1119 "property_declaration"
1120 "_function_body"
1121 "break_statement"
1122 "continue_statement"
1123 "do_statement"
1124 "empty_statement"
1125 "expression_statement"
1126 "return_statement"
1127 "yield_statement"
1128 "throw_statement"
1129 "goto_statement"
1130 "local_declaration_statement")
1131 eos))
1070 (text 1132 (text
1071 ,(regexp-opt '("comment" 1133 ,(regexp-opt '("comment"
1072 "verbatim_string-literal" 1134 "verbatim_string-literal"
@@ -1100,6 +1162,18 @@ Key bindings:
1100 ("Struct" "\\`struct_declaration\\'" nil nil) 1162 ("Struct" "\\`struct_declaration\\'" nil nil)
1101 ("Method" "\\`method_declaration\\'" nil nil))) 1163 ("Method" "\\`method_declaration\\'" nil nil)))
1102 1164
1165 ;; Outline minor mode.
1166 (setq-local treesit-outline-predicate
1167 (rx bos (or "namespace_declaration"
1168 "class_declaration"
1169 "interface_declaration"
1170 "enum_declaration"
1171 "record_declaration"
1172 "struct_declaration"
1173 "method_declaration"
1174 "local_function_statement")
1175 eos))
1176
1103 (treesit-major-mode-setup) 1177 (treesit-major-mode-setup)
1104 1178
1105 (add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-ts-mode))) 1179 (add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-ts-mode)))
diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
index 7abf9ddaeb5..d117fe21590 100644
--- a/lisp/progmodes/go-ts-mode.el
+++ b/lisp/progmodes/go-ts-mode.el
@@ -290,6 +290,25 @@
290 "type_declaration"))) 290 "type_declaration")))
291 (setq-local treesit-defun-name-function #'go-ts-mode--defun-name) 291 (setq-local treesit-defun-name-function #'go-ts-mode--defun-name)
292 292
293 (setq-local treesit-thing-settings
294 `((go
295 (list
296 ,(rx bos (or "import_spec_list"
297 "var_spec_list"
298 "type_parameter_list"
299 "parameter_list"
300 "parenthesized_type"
301 "type_arguments"
302 "field_declaration_list"
303 "block"
304 "parenthesized_expression"
305 "special_argument_list"
306 "argument_list"
307 "literal_value")
308 eos))
309 (sentence
310 (or "declaration" "statement")))))
311
293 ;; Imenu. 312 ;; Imenu.
294 (setq-local treesit-simple-imenu-settings 313 (setq-local treesit-simple-imenu-settings
295 `(("Function" "\\`function_declaration\\'" nil nil) 314 `(("Function" "\\`function_declaration\\'" nil nil)
diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el
index a5d81449ae5..e948406d9b4 100644
--- a/lisp/progmodes/php-ts-mode.el
+++ b/lisp/progmodes/php-ts-mode.el
@@ -1470,6 +1470,22 @@ Depends on `c-ts-common-comment-setup'."
1470 `((php 1470 `((php
1471 (defun ,treesit-defun-type-regexp) 1471 (defun ,treesit-defun-type-regexp)
1472 (sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ",")))) 1472 (sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ","))))
1473 (list
1474 ,(rx bos (or "namespace_use_group"
1475 "enum_declaration_list"
1476 "declaration_list"
1477 "property_hook_list"
1478 "use_list"
1479 "anonymous_function_use_clause"
1480 "formal_parameters"
1481 "match_block"
1482 "switch_block"
1483 "compound_statement"
1484 "parenthesized_expression"
1485 "_array_destructing"
1486 "arguments"
1487 "_complex_string_part")
1488 eos))
1473 (sentence ,(regexp-opt 1489 (sentence ,(regexp-opt
1474 '("break_statement" 1490 '("break_statement"
1475 "case_statement" 1491 "case_statement"
diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el
index 0fe5fcc083b..ae2bc8ee78c 100644
--- a/lisp/progmodes/rust-ts-mode.el
+++ b/lisp/progmodes/rust-ts-mode.el
@@ -597,6 +597,40 @@ See `prettify-symbols-compose-predicate'."
597 "struct_item"))) 597 "struct_item")))
598 (setq-local treesit-defun-name-function #'rust-ts-mode--defun-name) 598 (setq-local treesit-defun-name-function #'rust-ts-mode--defun-name)
599 599
600 (setq-local treesit-thing-settings
601 `((rust
602 (list
603 ,(rx bos (or "token_tree_pattern"
604 "token_tree"
605 "attribute_item"
606 "inner_attribute_item"
607 "declaration_list"
608 "enum_variant_list"
609 "field_declaration_list"
610 "ordered_field_declaration_list"
611 "type_parameters"
612 "use_list"
613 "parameters"
614 "bracketed_type"
615 "array_type"
616 "for_lifetimes"
617 "tuple_type"
618 "unit_type"
619 "use_bounds"
620 "type_arguments"
621 "delim_token_tree"
622 "arguments"
623 "array_expression"
624 "parenthesized_expression"
625 "tuple_expression"
626 "unit_expression"
627 "field_initializer_list"
628 "match_block"
629 "block"
630 "tuple_pattern"
631 "slice_pattern")
632 eos)))))
633
600 (treesit-major-mode-setup))) 634 (treesit-major-mode-setup)))
601 635
602(derived-mode-add-parents 'rust-ts-mode '(rust-mode)) 636(derived-mode-add-parents 'rust-ts-mode '(rust-mode))