Add indent rules to js/typescript/tsx-ts-mode (bug#60074)

* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--indent-rules): Add in binary_expression and
jsx_fragment.
* lisp/progmodes/js.el (js--treesit-indent-rules): Add the same rules.
This commit is contained in:
Theodor Thornhill 2022-12-14 21:23:33 +01:00 committed by Yuan Fu
parent a54d5f500c
commit 2ca06aed7b
No known key found for this signature in database
GPG key ID: 56E19BC57664A442
2 changed files with 6 additions and 0 deletions

View file

@ -3445,12 +3445,15 @@ This function is intended for use in `after-change-functions'."
((parent-is "pair") parent-bol js-indent-level)
((parent-is "arrow_function") parent-bol js-indent-level)
((parent-is "parenthesized_expression") parent-bol js-indent-level)
((parent-is "binary_expression") parent-bol js-indent-level)
((parent-is "class_body") parent-bol js-indent-level)
((parent-is ,switch-case) parent-bol js-indent-level)
((parent-is "statement_block") parent-bol js-indent-level)
;; JSX
((parent-is "jsx_opening_element") parent js-indent-level)
((match "<" "jsx_fragment") parent 0)
((parent-is "jsx_fragment") parent js-indent-level)
((node-is "jsx_closing_element") parent 0)
((node-is "jsx_text") parent js-indent-level)
((parent-is "jsx_element") parent js-indent-level)

View file

@ -92,9 +92,12 @@ Argument LANGUAGE is either `typescript' or `tsx'."
((parent-is "class_body") parent-bol typescript-ts-mode-indent-offset)
((parent-is "arrow_function") parent-bol typescript-ts-mode-indent-offset)
((parent-is "parenthesized_expression") parent-bol typescript-ts-mode-indent-offset)
((parent-is "binary_expression") parent-bol typescript-ts-mode-indent-offset)
,@(when (eq language 'tsx)
`(((parent-is "jsx_opening_element") parent typescript-ts-mode-indent-offset)
((match "<" "jsx_fragment") parent 0)
((parent-is "jsx_fragment") parent typescript-ts-mode-indent-offset)
((node-is "jsx_closing_element") parent 0)
((parent-is "jsx_element") parent typescript-ts-mode-indent-offset)
((node-is "/") parent 0)