mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
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.
This commit is contained in:
parent
4f4105e622
commit
f3925732bc
4 changed files with 143 additions and 0 deletions
|
|
@ -1067,6 +1067,68 @@ Key bindings:
|
||||||
|
|
||||||
(setq-local treesit-thing-settings
|
(setq-local treesit-thing-settings
|
||||||
`((c-sharp
|
`((c-sharp
|
||||||
|
(list
|
||||||
|
,(rx bos (or "global_attribute"
|
||||||
|
"attribute_argument_list"
|
||||||
|
"attribute_list"
|
||||||
|
"enum_member_declaration_list"
|
||||||
|
"type_parameter_list"
|
||||||
|
"declaration_list"
|
||||||
|
"accessor_list"
|
||||||
|
"bracketed_parameter_list"
|
||||||
|
"parameter_list"
|
||||||
|
"argument_list"
|
||||||
|
"tuple_pattern"
|
||||||
|
"block"
|
||||||
|
"bracketed_argument_list"
|
||||||
|
"type_argument_list"
|
||||||
|
"array_rank_specifier"
|
||||||
|
"function_pointer_type"
|
||||||
|
"tuple_type"
|
||||||
|
"_for_statement_conditions"
|
||||||
|
"switch_body"
|
||||||
|
"catch_declaration"
|
||||||
|
"catch_filter_clause"
|
||||||
|
"parenthesized_pattern"
|
||||||
|
"list_pattern"
|
||||||
|
"positional_pattern_clause"
|
||||||
|
"property_pattern_clause"
|
||||||
|
"parenthesized_variable_designation"
|
||||||
|
"_switch_expression_body"
|
||||||
|
"interpolated_string_expression"
|
||||||
|
"interpolation"
|
||||||
|
"parenthesized_expression"
|
||||||
|
"_parenthesized_lvalue_expression"
|
||||||
|
"anonymous_object_creation_expression"
|
||||||
|
"initializer_expression"
|
||||||
|
"_with_body"
|
||||||
|
"tuple_expression"
|
||||||
|
"preproc_parenthesized_expression")
|
||||||
|
eos))
|
||||||
|
(sentence
|
||||||
|
,(rx bos (or "extern_alias_directive"
|
||||||
|
"using_directive"
|
||||||
|
"file_scoped_namespace_declaration"
|
||||||
|
"enum_declaration"
|
||||||
|
"delegate_declaration"
|
||||||
|
"_declaration_list_body"
|
||||||
|
"field_declaration"
|
||||||
|
"event_declaration"
|
||||||
|
"event_field_declaration"
|
||||||
|
"indexer_declaration"
|
||||||
|
"property_declaration"
|
||||||
|
"_function_body"
|
||||||
|
"break_statement"
|
||||||
|
"continue_statement"
|
||||||
|
"do_statement"
|
||||||
|
"empty_statement"
|
||||||
|
"expression_statement"
|
||||||
|
"return_statement"
|
||||||
|
"yield_statement"
|
||||||
|
"throw_statement"
|
||||||
|
"goto_statement"
|
||||||
|
"local_declaration_statement")
|
||||||
|
eos))
|
||||||
(text
|
(text
|
||||||
,(regexp-opt '("comment"
|
,(regexp-opt '("comment"
|
||||||
"verbatim_string-literal"
|
"verbatim_string-literal"
|
||||||
|
|
@ -1100,6 +1162,18 @@ Key bindings:
|
||||||
("Struct" "\\`struct_declaration\\'" nil nil)
|
("Struct" "\\`struct_declaration\\'" nil nil)
|
||||||
("Method" "\\`method_declaration\\'" nil nil)))
|
("Method" "\\`method_declaration\\'" nil nil)))
|
||||||
|
|
||||||
|
;; Outline minor mode.
|
||||||
|
(setq-local treesit-outline-predicate
|
||||||
|
(rx bos (or "namespace_declaration"
|
||||||
|
"class_declaration"
|
||||||
|
"interface_declaration"
|
||||||
|
"enum_declaration"
|
||||||
|
"record_declaration"
|
||||||
|
"struct_declaration"
|
||||||
|
"method_declaration"
|
||||||
|
"local_function_statement")
|
||||||
|
eos))
|
||||||
|
|
||||||
(treesit-major-mode-setup)
|
(treesit-major-mode-setup)
|
||||||
|
|
||||||
(add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-ts-mode)))
|
(add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-ts-mode)))
|
||||||
|
|
|
||||||
|
|
@ -290,6 +290,25 @@
|
||||||
"type_declaration")))
|
"type_declaration")))
|
||||||
(setq-local treesit-defun-name-function #'go-ts-mode--defun-name)
|
(setq-local treesit-defun-name-function #'go-ts-mode--defun-name)
|
||||||
|
|
||||||
|
(setq-local treesit-thing-settings
|
||||||
|
`((go
|
||||||
|
(list
|
||||||
|
,(rx bos (or "import_spec_list"
|
||||||
|
"var_spec_list"
|
||||||
|
"type_parameter_list"
|
||||||
|
"parameter_list"
|
||||||
|
"parenthesized_type"
|
||||||
|
"type_arguments"
|
||||||
|
"field_declaration_list"
|
||||||
|
"block"
|
||||||
|
"parenthesized_expression"
|
||||||
|
"special_argument_list"
|
||||||
|
"argument_list"
|
||||||
|
"literal_value")
|
||||||
|
eos))
|
||||||
|
(sentence
|
||||||
|
(or "declaration" "statement")))))
|
||||||
|
|
||||||
;; Imenu.
|
;; Imenu.
|
||||||
(setq-local treesit-simple-imenu-settings
|
(setq-local treesit-simple-imenu-settings
|
||||||
`(("Function" "\\`function_declaration\\'" nil nil)
|
`(("Function" "\\`function_declaration\\'" nil nil)
|
||||||
|
|
|
||||||
|
|
@ -1470,6 +1470,22 @@ Depends on `c-ts-common-comment-setup'."
|
||||||
`((php
|
`((php
|
||||||
(defun ,treesit-defun-type-regexp)
|
(defun ,treesit-defun-type-regexp)
|
||||||
(sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ","))))
|
(sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ","))))
|
||||||
|
(list
|
||||||
|
,(rx bos (or "namespace_use_group"
|
||||||
|
"enum_declaration_list"
|
||||||
|
"declaration_list"
|
||||||
|
"property_hook_list"
|
||||||
|
"use_list"
|
||||||
|
"anonymous_function_use_clause"
|
||||||
|
"formal_parameters"
|
||||||
|
"match_block"
|
||||||
|
"switch_block"
|
||||||
|
"compound_statement"
|
||||||
|
"parenthesized_expression"
|
||||||
|
"_array_destructing"
|
||||||
|
"arguments"
|
||||||
|
"_complex_string_part")
|
||||||
|
eos))
|
||||||
(sentence ,(regexp-opt
|
(sentence ,(regexp-opt
|
||||||
'("break_statement"
|
'("break_statement"
|
||||||
"case_statement"
|
"case_statement"
|
||||||
|
|
|
||||||
|
|
@ -597,6 +597,40 @@ See `prettify-symbols-compose-predicate'."
|
||||||
"struct_item")))
|
"struct_item")))
|
||||||
(setq-local treesit-defun-name-function #'rust-ts-mode--defun-name)
|
(setq-local treesit-defun-name-function #'rust-ts-mode--defun-name)
|
||||||
|
|
||||||
|
(setq-local treesit-thing-settings
|
||||||
|
`((rust
|
||||||
|
(list
|
||||||
|
,(rx bos (or "token_tree_pattern"
|
||||||
|
"token_tree"
|
||||||
|
"attribute_item"
|
||||||
|
"inner_attribute_item"
|
||||||
|
"declaration_list"
|
||||||
|
"enum_variant_list"
|
||||||
|
"field_declaration_list"
|
||||||
|
"ordered_field_declaration_list"
|
||||||
|
"type_parameters"
|
||||||
|
"use_list"
|
||||||
|
"parameters"
|
||||||
|
"bracketed_type"
|
||||||
|
"array_type"
|
||||||
|
"for_lifetimes"
|
||||||
|
"tuple_type"
|
||||||
|
"unit_type"
|
||||||
|
"use_bounds"
|
||||||
|
"type_arguments"
|
||||||
|
"delim_token_tree"
|
||||||
|
"arguments"
|
||||||
|
"array_expression"
|
||||||
|
"parenthesized_expression"
|
||||||
|
"tuple_expression"
|
||||||
|
"unit_expression"
|
||||||
|
"field_initializer_list"
|
||||||
|
"match_block"
|
||||||
|
"block"
|
||||||
|
"tuple_pattern"
|
||||||
|
"slice_pattern")
|
||||||
|
eos)))))
|
||||||
|
|
||||||
(treesit-major-mode-setup)))
|
(treesit-major-mode-setup)))
|
||||||
|
|
||||||
(derived-mode-add-parents 'rust-ts-mode '(rust-mode))
|
(derived-mode-add-parents 'rust-ts-mode '(rust-mode))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue