ruby-ts-mode: Obey the option ruby-method-call-indent

* lisp/progmodes/ruby-ts-mode.el
(ruby-ts--method-call-indent-p): New function.
(ruby-ts--indent-rules): Use it.

* test/lisp/progmodes/ruby-ts-mode-tests.el:
Run indent test for ruby-method-call-indent.rb.

* test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb:
Add explicit value for ruby-method-call-indent.
This commit is contained in:
Dmitry Gutov 2023-01-18 03:21:32 +02:00
parent 045404d1aa
commit 343b9b3dfe
3 changed files with 12 additions and 0 deletions

View file

@ -640,6 +640,13 @@ a statement container is a node that matches
;; else the second query aligns
;; `ruby-indent-level' spaces in from the parent.
((and ruby-ts--align-chain-p (match "\\." "call")) ruby-ts--align-chain 0)
;; Obery ruby-method-call-indent, whether the dot is on
;; this line or the previous line.
((and (not ruby-ts--method-call-indent-p)
(or
(match "\\." "call")
(query "(call \".\" (identifier) @indent)")))
parent 0)
((match "\\." "call") parent ruby-indent-level)
;; ruby-indent-after-block-in-continued-expression
@ -797,6 +804,9 @@ a statement container is a node that matches
(defun ruby-ts--after-op-indent-p (&rest _)
ruby-after-operator-indent)
(defun ruby-ts--method-call-indent-p (&rest _)
ruby-method-call-indent)
(defun ruby-ts--class-or-module-p (node)
"Predicate if NODE is a class or module."
(string-match-p ruby-ts--class-or-module-regex (treesit-node-type node)))

View file

@ -58,5 +58,6 @@
# mode: ruby-ts
# ruby-after-operator-indent: t
# ruby-block-indent: t
# ruby-method-call-indent: t
# ruby-method-params-indent: t
# End:

View file

@ -253,6 +253,7 @@ The whitespace before and including \"|\" on each line is removed."
(ruby-ts-deftest-indent "ruby-ts.rb")
(ruby-ts-deftest-indent "ruby-after-operator-indent.rb")
(ruby-ts-deftest-indent "ruby-block-indent.rb")
(ruby-ts-deftest-indent "ruby-method-call-indent.rb")
(ruby-ts-deftest-indent "ruby-method-params-indent.rb")
(provide 'ruby-ts-mode-tests)