Last active
September 1, 2024 19:57
-
-
Save aaronjensen/738eee25323dba36029a852baee495e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defcustom ruby-bracketed-args-indent t | |
"Non-nil to align the contents of bracketed arguments with the brackets. | |
Example: | |
qux({ | |
foo => bar | |
}) | |
Set it to nil to align to the beginning of the statement: | |
qux({ | |
foo => bar | |
}) | |
Only has effect when `ruby-use-smie' is t." | |
:type 'boolean | |
:safe 'booleanp | |
:version "31.1") | |
(defun aj-ruby-smie-before-paren-advice (orig-fun kind token) | |
"Patch for ruby-smie-rules to handle custom bracketed args indentation." | |
(if (and (eq kind :before) | |
(member token '("(" "[" "{")) | |
(not (eq ruby-bracketed-args-indent t)) | |
(smie-rule-prev-p "," "(" "[") | |
(smie-rule-hanging-p)) | |
(cons 'column (current-indentation)) | |
(funcall orig-fun kind token))) | |
(advice-add 'ruby-smie-rules :around #'aj-ruby-smie-before-paren-advice) | |
(setq ruby-bracketed-args-indent nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment