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:
parent
6c15b7710d
commit
24f12bdd77
4 changed files with 32 additions and 7 deletions
4
etc/NEWS
4
etc/NEWS
|
@ -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
|
Gemfile and act accordingly. But you can also set it to t or nil to
|
||||||
skip the check.
|
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
|
** Thingatpt
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -842,6 +842,16 @@ a statement container is a node that matches
|
||||||
;; No paren/curly/brace found on the same line.
|
;; No paren/curly/brace found on the same line.
|
||||||
((< (treesit-node-start found) parent-bol)
|
((< (treesit-node-start found) parent-bol)
|
||||||
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.
|
;; Hash or array opener on the same line.
|
||||||
((string-match-p "\\`array\\|hash\\'" (treesit-node-type found))
|
((string-match-p "\\`array\\|hash\\'" (treesit-node-type found))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
update({
|
foo
|
||||||
key => value,
|
.update({
|
||||||
other_key:
|
key => value,
|
||||||
}, {
|
other_key:
|
||||||
key => value,
|
}, {
|
||||||
other_key:
|
key => value,
|
||||||
})
|
other_key:
|
||||||
|
})
|
||||||
|
|
||||||
update([
|
update([
|
||||||
1,
|
1,
|
||||||
|
@ -27,6 +28,15 @@
|
||||||
2
|
2
|
||||||
], arg2)
|
], arg2)
|
||||||
|
|
||||||
|
def foo
|
||||||
|
foo.update(
|
||||||
|
{
|
||||||
|
key => value,
|
||||||
|
other_key: foo
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
# Local Variables:
|
# Local Variables:
|
||||||
# ruby-bracketed-args-indent: nil
|
# ruby-bracketed-args-indent: nil
|
||||||
# End:
|
# End:
|
||||||
|
|
|
@ -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-call-indent.rb")
|
||||||
(ruby-ts-deftest-indent "ruby-method-params-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-parenless-call-arguments-indent.rb")
|
||||||
|
(ruby-ts-deftest-indent "ruby-bracketed-args-indent.rb")
|
||||||
|
|
||||||
(provide 'ruby-ts-mode-tests)
|
(provide 'ruby-ts-mode-tests)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue