[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 44c9cb8653: Improve indentation for jsx
From: |
Theodor Thornhill |
Subject: |
emacs-29 44c9cb8653: Improve indentation for jsx |
Date: |
Sun, 15 Jan 2023 15:51:41 -0500 (EST) |
branch: emacs-29
commit 44c9cb8653d19843b5e9f131b139aad7c1c4774b
Author: Theodor Thornhill <theo@thornhill.no>
Commit: Theodor Thornhill <theo@thornhill.no>
Improve indentation for jsx
* lisp/progmodes/js.el (js--treesit-indent-rules): Use more parent
anchors and fix typo with wrong indent offset variable.
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--indent-rules): Use more parent anchors.
---
lisp/progmodes/js.el | 15 +++++++++------
lisp/progmodes/typescript-ts-mode.el | 14 ++++++++------
2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 058c8907bb..cc556c4d0e 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3454,13 +3454,16 @@ This function is intended for use in
`after-change-functions'."
((parent-is "statement_block") parent-bol js-indent-level)
;; JSX
- ((node-is "jsx_fragment") parent typescript-ts-mode-indent-offset)
- ((node-is "jsx_element") parent typescript-ts-mode-indent-offset)
- ((node-is "jsx_expression") parent typescript-ts-mode-indent-offset)
- ((node-is "jsx_self_closing_element") parent
typescript-ts-mode-indent-offset)
+ ((match "<" "jsx_fragment") parent 0)
+ ((parent-is "jsx_fragment") parent js-indent-level)
((node-is "jsx_closing_element") parent 0)
- ((node-is "/") parent 0)
- ((node-is ">") parent 0)))))
+ ((node-is "jsx_element") parent js-indent-level)
+ ((parent-is "jsx_element") parent js-indent-level)
+ ((parent-is "jsx_opening_element") parent js-indent-level)
+ ((parent-is "jsx_expression") parent-bol js-indent-level)
+ ((match "/" "jsx_self_closing_element") parent 0)
+ ((parent-is "jsx_self_closing_element") parent js-indent-level)
+ (no-node parent-bol 0)))))
(defvar js--treesit-keywords
'("as" "async" "await" "break" "case" "catch" "class" "const" "continue"
diff --git a/lisp/progmodes/typescript-ts-mode.el
b/lisp/progmodes/typescript-ts-mode.el
index 037d5c8e87..ffd5b941da 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -97,13 +97,15 @@ Argument LANGUAGE is either `typescript' or `tsx'."
((parent-is "binary_expression") parent-bol
typescript-ts-mode-indent-offset)
,@(when (eq language 'tsx)
- `(((node-is "jsx_fragment") parent typescript-ts-mode-indent-offset)
- ((node-is "jsx_element") parent typescript-ts-mode-indent-offset)
- ((node-is "jsx_expression") parent typescript-ts-mode-indent-offset)
- ((node-is "jsx_self_closing_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)
- ((node-is "/") parent 0)
- ((node-is ">") parent 0)))
+ ((node-is "jsx_element") parent typescript-ts-mode-indent-offset)
+ ((parent-is "jsx_element") parent typescript-ts-mode-indent-offset)
+ ((parent-is "jsx_opening_element") parent
typescript-ts-mode-indent-offset)
+ ((parent-is "jsx_expression") parent-bol
typescript-ts-mode-indent-offset)
+ ((match "/" "jsx_self_closing_element") parent 0)
+ ((parent-is "jsx_self_closing_element") parent
typescript-ts-mode-indent-offset)))
(no-node parent-bol 0))))
(defvar typescript-ts-mode--keywords
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 44c9cb8653: Improve indentation for jsx,
Theodor Thornhill <=