From 82b82209bab9dd8f0eb477c6831416db5e08eb37 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Fri, 25 Apr 2025 17:38:58 -0700 Subject: [PATCH] Add multivar indent style in typescript-ts-mode (bug#77803) * lisp/progmodes/typescript-ts-mode.el: (typescript-ts-mode-multivar-indent-style): New option. (typescript-ts-mode--indent-rules): Support both styles. (cherry picked from commit 3393644b715a4b5a1b438b556478cc9e45f3e0ad) --- lisp/progmodes/typescript-ts-mode.el | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 9b5b7312e1c..aaeedae86c4 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -62,6 +62,26 @@ :safe 'integerp :group 'typescript) +(defcustom typescript-ts-mode-multivar-indent-style 'indent + "Indentation style for multivar declaration. + +If the value is `align', align each declaration: + + const foo = 'bar', + car = 'cdr', + stop = 'start'; + +If the value is `indent', indent subsequent declarations by one indent +level: + + const foo = 'bar', + car = 'cdr', + stop = 'start'; + +For changes to this variable to take effect, restart the major mode." + :version "31.1" + :type 'symbol) + (defface typescript-ts-jsx-tag-face '((t . (:inherit font-lock-function-call-face))) "Face for HTML tags like
and

in JSX." @@ -153,7 +173,9 @@ Argument LANGUAGE is either `typescript' or `tsx'." ((parent-is "type_arguments") parent-bol typescript-ts-mode-indent-offset) ((parent-is "type_parameters") parent-bol typescript-ts-mode-indent-offset) ((parent-is ,(rx (or "variable" "lexical") "_" (or "declaration" "declarator"))) - parent-bol typescript-ts-mode-indent-offset) + ,@(pcase typescript-ts-mode-multivar-indent-style + ('indent '(parent-bol typescript-ts-mode-indent-offset)) + ('align '(typescript-ts-mode--anchor-decl 1)))) ((parent-is "arguments") parent-bol typescript-ts-mode-indent-offset) ((parent-is "array") parent-bol typescript-ts-mode-indent-offset) ((parent-is "formal_parameters") parent-bol typescript-ts-mode-indent-offset) -- 2.39.5