]> git.eshelyaron.com Git - emacs.git/commitdiff
ruby-ts-mode: Obey the option ruby-method-call-indent
authorDmitry Gutov <dgutov@yandex.ru>
Wed, 18 Jan 2023 01:21:32 +0000 (03:21 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Wed, 18 Jan 2023 01:27:37 +0000 (03:27 +0200)
* 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.

lisp/progmodes/ruby-ts-mode.el
test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb
test/lisp/progmodes/ruby-ts-mode-tests.el

index 7e30ece1fd7db7c448ee49b3f01b9eb9e13b65cb..27e5d00288169ee9ebde095395a6b34632c9ab92 100644 (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)))
index be98465881fd708e42ee5ec3ed474ffb5eeca565..9959de4fe71fa6874eae6e759f91a5fbc7de1032 100644 (file)
@@ -58,5 +58,6 @@ qux = foo.fee ?
 # mode: ruby-ts
 # ruby-after-operator-indent: t
 # ruby-block-indent: t
+# ruby-method-call-indent: t
 # ruby-method-params-indent: t
 # End:
index 1d686a2ac5354d8f9e3a85d4945a460f3e46ca39..1d2cfbfb90153c05f12367f10c63f8b472959e79 100644 (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)