Skip to content

Commit a1fcbf2

Browse files
committed
[Fix #1421] Make the format action in TypeScript code configurable
1 parent 3caedeb commit a1fcbf2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Add a F# module.
1515
* Auto-install `use-package`.
1616
* Add `prelude-vertico` module. Vertico a simpler alternative to `ivy-mode` and supersedes Selectrum.
17+
* Make it possible to configure the TypeScript format action using `prelude-ts-format-action`.
1718

1819
### Changes
1920

modules/prelude-ts.el

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434

3535
(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode))
3636

37+
(defcustom prelude-ts-format-action #'tide-format-before-save
38+
"The format function to invoke on save.
39+
40+
Triggered only when `prelude-format-on-save' is enabled."
41+
:package-version '(prelude . "1.2"))
42+
3743
(with-eval-after-load 'typescript-mode
3844
(defun prelude-ts-mode-defaults ()
3945
(interactive)
@@ -46,8 +52,8 @@
4652
;; formats the buffer before saving
4753
(add-hook 'before-save-hook
4854
(lambda ()
49-
(when prelude-format-on-save
50-
(tide-format-before-save))))
55+
(when (and prelude-format-on-save prelude-ts-format-action)
56+
(funcall prelude-ts-format-action))))
5157

5258
(setq prelude-ts-mode-hook 'prelude-ts-mode-defaults)
5359

0 commit comments

Comments
 (0)