ruby-ts-mode: Obey the option ruby-after-operator-indent
* 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.
This commit is contained in:
parent
300ca6ac37
commit
045404d1aa
3 changed files with 12 additions and 1 deletions
|
@ -685,6 +685,10 @@ a statement container is a node that matches
|
||||||
;; Old... probably too simple
|
;; Old... probably too simple
|
||||||
((parent-is "block_parameters") first-sibling 1)
|
((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")
|
((parent-is "binary")
|
||||||
ruby-ts--binary-indent-anchor 0)
|
ruby-ts--binary-indent-anchor 0)
|
||||||
|
|
||||||
|
@ -790,6 +794,9 @@ a statement container is a node that matches
|
||||||
(forward-char ruby-indent-level))
|
(forward-char ruby-indent-level))
|
||||||
(point)))
|
(point)))
|
||||||
|
|
||||||
|
(defun ruby-ts--after-op-indent-p (&rest _)
|
||||||
|
ruby-after-operator-indent)
|
||||||
|
|
||||||
(defun ruby-ts--class-or-module-p (node)
|
(defun ruby-ts--class-or-module-p (node)
|
||||||
"Predicate if NODE is a class or module."
|
"Predicate if NODE is a class or module."
|
||||||
(string-match-p ruby-ts--class-or-module-regex (treesit-node-type node)))
|
(string-match-p ruby-ts--class-or-module-regex (treesit-node-type node)))
|
||||||
|
|
|
@ -56,4 +56,7 @@
|
||||||
|
|
||||||
# Local Variables:
|
# Local Variables:
|
||||||
# mode: ruby-ts
|
# mode: ruby-ts
|
||||||
|
# ruby-after-operator-indent: t
|
||||||
|
# ruby-block-indent: t
|
||||||
|
# ruby-method-params-indent: t
|
||||||
# End:
|
# End:
|
||||||
|
|
|
@ -251,8 +251,9 @@ The whitespace before and including \"|\" on each line is removed."
|
||||||
(kill-buffer buf)))))
|
(kill-buffer buf)))))
|
||||||
|
|
||||||
(ruby-ts-deftest-indent "ruby-ts.rb")
|
(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-block-indent.rb")
|
||||||
|
(ruby-ts-deftest-indent "ruby-method-params-indent.rb")
|
||||||
|
|
||||||
(provide 'ruby-ts-mode-tests)
|
(provide 'ruby-ts-mode-tests)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue