1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-21 06:55:39 +00:00

Support the new option in ruby-ts-mode too

* etc/NEWS: Describe it here.

* lisp/progmodes/ruby-ts-mode.el (ruby-ts--parent-call-or-bol):
Support the option ruby-bracketed-args-indent here too (bug#60321).

* test/lisp/progmodes/ruby-ts-mode-tests.el: Include
ruby-bracketed-args-indent.rb as test examples.

* test/lisp/progmodes/ruby-mode-resources/ruby-bracketed-args-indent.rb:
Extend examples for better regression testing.
This commit is contained in:
Dmitry Gutov 2024-09-02 21:02:21 +03:00
parent 6c15b7710d
commit 24f12bdd77
4 changed files with 32 additions and 7 deletions

View File

@ -1973,6 +1973,10 @@ By default it retains the previous behavior: read the contents of
Gemfile and act accordingly. But you can also set it to t or nil to
skip the check.
*** New user option 'ruby-bracketed-args-indent'.
When it is set to nil, multiple consecutive open braces/brackets/parens
result in only one additional indentation level.
** Thingatpt
---

View File

@ -842,6 +842,16 @@ a statement container is a node that matches
;; No paren/curly/brace found on the same line.
((< (treesit-node-start found) parent-bol)
parent-bol)
;; Nesting of brackets args.
((and
(not (eq ruby-bracketed-args-indent t))
(string-match-p "\\`array\\|hash\\'" (treesit-node-type parent))
(equal (treesit-node-parent parent) found)
;; Grandparent is not a parenless call.
(or (not (equal (treesit-node-type found) "argument_list"))
(equal (treesit-node-type (treesit-node-child found 0))
"(")))
parent-bol)
;; Hash or array opener on the same line.
((string-match-p "\\`array\\|hash\\'" (treesit-node-type found))
(save-excursion

View File

@ -1,10 +1,11 @@
update({
key => value,
other_key:
}, {
key => value,
other_key:
})
foo
.update({
key => value,
other_key:
}, {
key => value,
other_key:
})
update([
1,
@ -27,6 +28,15 @@
2
], arg2)
def foo
foo.update(
{
key => value,
other_key: foo
}
)
end
# Local Variables:
# ruby-bracketed-args-indent: nil
# End:

View File

@ -326,6 +326,7 @@ The whitespace before and including \"|\" on each line is removed."
(ruby-ts-deftest-indent "ruby-method-call-indent.rb")
(ruby-ts-deftest-indent "ruby-method-params-indent.rb")
(ruby-ts-deftest-indent "ruby-parenless-call-arguments-indent.rb")
(ruby-ts-deftest-indent "ruby-bracketed-args-indent.rb")
(provide 'ruby-ts-mode-tests)