unsure of correct configuration with use-package
dagda1 opened this issue · 6 comments
Currently my configuration is this:
(use-package prettier-js
:commands (prettier-mode prettier)
:init (add-hook 'js2-mode-hook 'prettier-mode)
:bind (:map js2-mode-map ("M-q" . prettier))
:config (setq prettier-target-mode "js2-mode"))
But when I hit M-q
I get this message in the gutter:
Autoloading failed to define function prettier
If I key M-x
and select prettier-js
then the code formats.
But if I select M-x
and prettier-mode
I get the autoloading error:
Autoloading failed to define function prettier
How can I have prettier-js enabled by default and to format the code after every save?
AFAICT the mode is called prettier-js-mode
, not prettier-mode
. Your config should be fine if you replace that.
also, the prettier
command was refactored to prettier-js-prettify, following the elisp prefixing style.
How can I configure prettier to run after a save in js2-mode?
prettier-js-mode
runs prettier-js-prettify
on save if the mode is activated. You just need to add a hook to js2. There is an example in the README.md
(add-hook 'js2-mode-hook 'prettier-js-mode)
If you want to load prettier-js with use-package, I believe you can do something like this
(use-package prettier-js
:init
(add-hook 'js2-mode-hook 'prettier-js-mode))
I hope this helps 😄
brilliant, works a treat.
You have no idea the config options I have been through to try and j2-mode or web-mode work with pure render functions without the parenthesis e.g.
const myComp = props =>
<div>foo</foo>
Now I finally have something that works.
Great work!
I'm glad you got it working! 🍻