diff --git a/core/prelude-custom.el b/core/prelude-custom.el index 3d66353..5a5410b 100644 --- a/core/prelude-custom.el +++ b/core/prelude-custom.el @@ -82,6 +82,12 @@ in the desired elisp file." :type 'list :group 'prelude) +(defcustom prelude-format-on-save t + "Run mode specific format on file before it's saved. +Currently only applies to tide-mode." + :type 'boolean + :group 'prelude) + (defcustom prelude-yank-indent-modes '(LaTeX-mode TeX-mode) "Modes in which to indent regions that are yanked (or yank-popped). Only modes that don't derive from `prog-mode' should be listed here." diff --git a/doc/configuration.md b/doc/configuration.md index d9f0346..384e26e 100644 --- a/doc/configuration.md +++ b/doc/configuration.md @@ -113,11 +113,6 @@ cleanup your file on save, you can disable that behavior by setting (setq prelude-clean-whitespace-on-save nil) ``` -The `prelude-clean-whitespace-on-save` setting can also be set on a -per-file or directory basis by using a file variable or a -`.dir-locals.el` file. - - ### Disable flyspell-mode If you're not fond of spellchecking on the fly: @@ -125,3 +120,19 @@ If you're not fond of spellchecking on the fly: ```lisp (setq prelude-flyspell nil) ``` + +### Disable automatic formatting on save + +If you prefer not to automatically format your file on save, you can disable that behavior by setting +`prelude-format-on-save` to `nil` in your config file with: + +```lisp +(setq prelude-format-on-save nil) +``` + +Currently this only affects automated formatting of Typescript files. + +### Configuration per file or directory + +These settings can also be set on a per-file or directory basis by using a file local variable or a `.dir-locals.el` +file. diff --git a/modules/prelude-ts.el b/modules/prelude-ts.el index 66e2fd3..50a96e0 100644 --- a/modules/prelude-ts.el +++ b/modules/prelude-ts.el @@ -48,7 +48,10 @@ (tide-hl-identifier-mode +1)) ;; formats the buffer before saving - (add-hook 'before-save-hook 'tide-format-before-save) + (add-hook 'before-save-hook + (lambda () + (when prelude-format-on-save + (tide-format-before-save)))) (setq prelude-ts-mode-hook 'prelude-ts-mode-defaults)