Always run prettier if prettier-mode is active (#1623)

This commit is contained in:
Roman Coedo authored and Christopher Chedeau committed 2017-05-18 08:56:59 -07:00
1 parent 2fd7199c11
commit 16ce76a082
2 files changed
+7 -9

No files matched your search

+4 -6
View File
@@ -2,15 +2,13 @@ Add this to your init:
```elisp
(require 'prettier-js)
(prettier-mode)
```
If you don't use `js-mode`, which is what Prettier targets by default, you'll need to first set your major-mode of choice:
Then you can hook to your favorite javascript mode:
```elisp
(require 'prettier-js)
(setq prettier-target-mode "js2-mode")
(prettier-mode)
(add-hook 'js2-mode-hook 'prettier-mode)
(add-hook 'web-mode-hook 'prettier-mode)
...
```
To adjust the CLI args used for the prettier command, you can customize the `prettier-args` variable:
+3 -3
View File
@@ -223,9 +223,9 @@ function."
(define-minor-mode prettier-mode
"Runs prettier on file save when this mode is turned on"
:lighter " prettier"
:global t
:global nil
(if prettier-mode
(add-hook 'before-save-hook 'prettier-before-save)
(remove-hook 'before-save-hook 'prettier-before-save)))
(add-hook 'before-save-hook 'prettier nil 'local)
(remove-hook 'before-save-hook 'prettier 'local)))
(provide 'prettier-js)