jscheid / prettier.el

Prettier code formatting for Emacs.
GNU General Public License v3.0
168 stars 12 forks source link

"Prettier syncing config" on every newline in org-babel js source block #100

Closed bi1yeu closed 2 years ago

bi1yeu commented 2 years ago

Describe the bug

Hi! I'm using Org Babel with a JavaScript code block like this:

#+begin_src js
console.log("Hello, World!");
#+end_src

Whenever I create a new line inside the source code block, the message "Prettier syncing config" appears in the minibuffer, and Emacs hangs for a moment. I don't know if this is a bug, per se, or even whether it's something than can be fixed by prettier.el, but it's impeding my workflow so I figured I'd ask. Any advice is appreciated, thanks in advance!

Link to M-x prettier-info output We suggest you copy the output into a Gist after sanitizing it. Make sure to run prettier-info in the buffer where you experienced the problem. If possible, include a copy of that buffer's contents in the Gist.

prettier-info.el

To Reproduce

  1. open a scratch buffer in org-mode
  2. create a js source code block
  3. put cursor inside code block and press Enter key
  4. observe the "Prettier syncing config" message

Expected behavior A clear and concise description of what you expected to happen.

I'd expect prettier config to sync only once (I think?)

Additional context Add any other context about the problem here.

I'm using doom-emacs.

jscheid commented 2 years ago

Hi, I can reproduce this. I'll have a look to see what can be done about it.

I'm wondering, does this package otherwise work alongside org-mode as you'd expect?

bi1yeu commented 2 years ago

I'm not a heavy user of either prettier nor org babel, but I only recently installed prettier and noticed this issue.

Upon further investigation, it does not look like the JavaScript code inside of the Org source code block is being formatted by prettier when the buffer is saved. E.g., I put console.log( "Hello, World"); in a source code block and it's not reformatted. The same code in a js-mode buffer is reformatted as expected.

jscheid commented 2 years ago

This should be fixed in the latest release.

I've also added an (experimental) function prettier-prettify-org-src-code-at-point. I might build this out into something more fully featured at a later point, perhaps spun out into its own package. If you are going to use it I'd be keen to hear how you go with it.

bi1yeu commented 2 years ago

Thanks!!

On Thu, May 26, 2022, at 3:40 AM, Julian Scheid wrote:

This should be fixed in the latest release.

I've also added an (experimental) function prettier-prettify-org-src-code-at-point. I might build this out into something more fully featured at a later point, perhaps spun out into its own package. If you are going to use it I'd be keen to hear how you go with it.

— Reply to this email directly, view it on GitHub https://github.com/jscheid/prettier.el/issues/100#issuecomment-1138397563, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJBK2JXCD57QHUQWLZSCGTVL5IK5ANCNFSM5K47DM5A. You are receiving this because you authored the thread.Message ID: @.***>