Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsure of correct configuration with use-package #8

Closed
dagda1 opened this issue Jun 27, 2017 · 6 comments
Closed

unsure of correct configuration with use-package #8

dagda1 opened this issue Jun 27, 2017 · 6 comments

Comments

@dagda1
Copy link

dagda1 commented Jun 27, 2017

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?

@eqyiel
Copy link
Contributor

eqyiel commented Jun 28, 2017

AFAICT the mode is called prettier-js-mode, not prettier-mode. Your config should be fine if you replace that.

@dagda1 dagda1 closed this as completed Jun 28, 2017
@rcoedo
Copy link

rcoedo commented Jun 28, 2017

also, the prettier command was refactored to prettier-js-prettify, following the elisp prefixing style.

@dagda1
Copy link
Author

dagda1 commented Jun 28, 2017

How can I configure prettier to run after a save in js2-mode?

@rcoedo
Copy link

rcoedo commented Jun 28, 2017

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 😄

@dagda1
Copy link
Author

dagda1 commented Jun 28, 2017

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!

@rcoedo
Copy link

rcoedo commented Jun 28, 2017

I'm glad you got it working! 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants