Allow auto-formatting of files to be controlled (#1254)

This commit is contained in:
RohanHart 2020-04-09 18:58:07 +12:00 committed by GitHub
parent a7c82c865c
commit 33c21ff1fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 6 deletions

View file

@ -82,6 +82,12 @@ in the desired elisp file."
:type 'list :type 'list
:group 'prelude) :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) (defcustom prelude-yank-indent-modes '(LaTeX-mode TeX-mode)
"Modes in which to indent regions that are yanked (or yank-popped). "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." Only modes that don't derive from `prog-mode' should be listed here."

View file

@ -113,11 +113,6 @@ cleanup your file on save, you can disable that behavior by setting
(setq prelude-clean-whitespace-on-save nil) (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 ### Disable flyspell-mode
If you're not fond of spellchecking on the fly: 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 ```lisp
(setq prelude-flyspell nil) (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.

View file

@ -48,7 +48,10 @@
(tide-hl-identifier-mode +1)) (tide-hl-identifier-mode +1))
;; formats the buffer before saving ;; 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) (setq prelude-ts-mode-hook 'prelude-ts-mode-defaults)