]> git.eshelyaron.com Git - emacs.git/commitdiff
ruby-ts-mode: Obey the option ruby-after-operator-indent
authorDmitry Gutov <dgutov@yandex.ru>
Wed, 18 Jan 2023 00:55:09 +0000 (02:55 +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--after-op-indent-p): New function.
(ruby-ts--indent-rules): Use it.

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

* test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb:
Make sure indentation vars are at their default values.

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

index e629ff1967212cd6a1e5f2e4ca3ef34cfd973096..7e30ece1fd7db7c448ee49b3f01b9eb9e13b65cb 100644 (file)
@@ -685,6 +685,10 @@ a statement container is a node that matches
            ;; Old... probably too simple
            ((parent-is "block_parameters") first-sibling 1)
 
+           ((and (not ruby-ts--after-op-indent-p)
+                 (parent-is "binary\\|conditional"))
+            (ruby-ts--bol ruby-ts--statement-ancestor) ruby-indent-level)
+
            ((parent-is "binary")
             ruby-ts--binary-indent-anchor 0)
 
@@ -790,6 +794,9 @@ a statement container is a node that matches
       (forward-char ruby-indent-level))
     (point)))
 
+(defun ruby-ts--after-op-indent-p (&rest _)
+  ruby-after-operator-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 92d62f92e52693c4bba3c5aefe79a310648073dc..be98465881fd708e42ee5ec3ed474ffb5eeca565 100644 (file)
@@ -56,4 +56,7 @@ qux = foo.fee ?
 
 # Local Variables:
 # mode: ruby-ts
+# ruby-after-operator-indent: t
+# ruby-block-indent: t
+# ruby-method-params-indent: t
 # End:
index d7b6258385b17e536a0450d7b0b6c84fc448abd7..1d686a2ac5354d8f9e3a85d4945a460f3e46ca39 100644 (file)
@@ -251,8 +251,9 @@ The whitespace before and including \"|\" on each line is removed."
          (kill-buffer buf)))))
 
 (ruby-ts-deftest-indent "ruby-ts.rb")
-(ruby-ts-deftest-indent "ruby-method-params-indent.rb")
+(ruby-ts-deftest-indent "ruby-after-operator-indent.rb")
 (ruby-ts-deftest-indent "ruby-block-indent.rb")
+(ruby-ts-deftest-indent "ruby-method-params-indent.rb")
 
 (provide 'ruby-ts-mode-tests)