[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b3a44ff3247: ruby-ts-mode: Do not treat parenless calls' args as
From: |
Dmitry Gutov |
Subject: |
master b3a44ff3247: ruby-ts-mode: Do not treat parenless calls' args as separate sexp |
Date: |
Tue, 11 Apr 2023 19:28:16 -0400 (EDT) |
branch: master
commit b3a44ff3247dff54659f9f61daf297d3bdc8e2f4
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
ruby-ts-mode: Do not treat parenless calls' args as separate sexp
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--sexp-p): New function.
(ruby-ts-mode): Use it in treesit-sexp-type-regexp (bug#62086).
---
lisp/progmodes/ruby-ts-mode.el | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index ddf2ee98c3b..7a00977f14a 100644
--- a/lisp/progmodes/ruby-ts-mode.el
+++ b/lisp/progmodes/ruby-ts-mode.el
@@ -1086,6 +1086,15 @@ leading double colon is not added."
(put-text-property pos (1+ pos) 'syntax-table
(string-to-syntax "!"))))))))
+(defun ruby-ts--sexp-p (node)
+ ;; Skip parenless calls (implicit parens are both non-obvious to the
+ ;; user, and might take over when we want to just over some physical
+ ;; parens/braces).
+ (or (not (equal (treesit-node-type node)
+ "argument_list"))
+ (equal (treesit-node-type (treesit-node-child node 0))
+ "(")))
+
(defvar-keymap ruby-ts-mode-map
:doc "Keymap used in Ruby mode"
:parent prog-mode-map
@@ -1114,8 +1123,10 @@ leading double colon is not added."
(setq-local treesit-defun-type-regexp ruby-ts--method-regex)
(setq-local treesit-sexp-type-regexp
- (rx bol
- (or "class"
+ (cons (rx
+ bol
+ (or
+ "class"
"module"
"method"
"array"
@@ -1147,7 +1158,8 @@ leading double colon is not added."
"instance_variable"
"global_variable"
)
- eol))
+ eol)
+ #'ruby-ts--sexp-p))
;; AFAIK, Ruby can not nest methods
(setq-local treesit-defun-prefer-top-level nil)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master b3a44ff3247: ruby-ts-mode: Do not treat parenless calls' args as separate sexp,
Dmitry Gutov <=