diff options
| author | Dmitry Gutov | 2023-03-29 01:08:55 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2023-03-29 01:08:55 +0300 |
| commit | 2002ac376c97382cace161ef0832a6faf6f376e8 (patch) | |
| tree | b32425675f30e8e48c178aa0b82be58629e0ffab | |
| parent | cde38f0df3fa3540ce411a48d95da1c2f1be1b60 (diff) | |
| download | emacs-2002ac376c97382cace161ef0832a6faf6f376e8.tar.gz emacs-2002ac376c97382cace161ef0832a6faf6f376e8.zip | |
ruby-ts-mode: Rehash which nodes should be treated as sexps
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): Recognize smaller
syntactic elements as sexps too (bug#62416). Also do that for
heredocs, regexps and symbol arrays. But drop binary expressions
(including assignments) since they led to non-intuitive behavior.
| -rw-r--r-- | lisp/progmodes/ruby-ts-mode.el | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 97c7cf6480c..1a085b669ee 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el | |||
| @@ -1114,21 +1114,32 @@ leading double colon is not added." | |||
| 1114 | (setq-local treesit-defun-type-regexp ruby-ts--method-regex) | 1114 | (setq-local treesit-defun-type-regexp ruby-ts--method-regex) |
| 1115 | 1115 | ||
| 1116 | (setq-local treesit-sexp-type-regexp | 1116 | (setq-local treesit-sexp-type-regexp |
| 1117 | (regexp-opt '("class" | 1117 | (rx bol |
| 1118 | "module" | 1118 | (or "class" |
| 1119 | "method" | 1119 | "module" |
| 1120 | "argument_list" | 1120 | "method" |
| 1121 | "array" | 1121 | "array" |
| 1122 | "hash" | 1122 | "hash" |
| 1123 | "parenthesized_statements" | 1123 | "parenthesized_statements" |
| 1124 | "if" | 1124 | "if" |
| 1125 | "case" | 1125 | "case" |
| 1126 | "when" | 1126 | "when" |
| 1127 | "block" | 1127 | "block" |
| 1128 | "do_block" | 1128 | "do_block" |
| 1129 | "begin" | 1129 | "begin" |
| 1130 | "binary" | 1130 | "integer" |
| 1131 | "assignment"))) | 1131 | "identifier" |
| 1132 | "constant" | ||
| 1133 | "simple_symbol" | ||
| 1134 | "symbol_array" | ||
| 1135 | "hash_key_symbol" | ||
| 1136 | "string" | ||
| 1137 | "string_array" | ||
| 1138 | "heredoc_body" | ||
| 1139 | "regex" | ||
| 1140 | "argument_list" | ||
| 1141 | ) | ||
| 1142 | eol)) | ||
| 1132 | 1143 | ||
| 1133 | ;; AFAIK, Ruby can not nest methods | 1144 | ;; AFAIK, Ruby can not nest methods |
| 1134 | (setq-local treesit-defun-prefer-top-level nil) | 1145 | (setq-local treesit-defun-prefer-top-level nil) |