emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 2ca06aed7b: Add indent rules to js/typescript/tsx-ts-mode (bug#


From: Yuan Fu
Subject: emacs-29 2ca06aed7b: Add indent rules to js/typescript/tsx-ts-mode (bug#60074)
Date: Wed, 14 Dec 2022 17:41:23 -0500 (EST)

branch: emacs-29
commit 2ca06aed7b39afdc00041ab7cd9c7a8cb50332f6
Author: Theodor Thornhill <theo@thornhill.no>
Commit: Yuan Fu <casouri@gmail.com>

    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.
---
 lisp/progmodes/js.el                 | 3 +++
 lisp/progmodes/typescript-ts-mode.el | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 02990813ef..8ec14cf7ad 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -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)
diff --git a/lisp/progmodes/typescript-ts-mode.el 
b/lisp/progmodes/typescript-ts-mode.el
index b8a921e9c2..e7bd65c5e2 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]