jscheid / prettier.el

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

make formatting on save optional; note formatting desires to flycheck? #98

Closed greg-minshall closed 2 years ago

greg-minshall commented 3 years ago

Is your feature request related to a problem? Please describe. I'm often frustrated when the code changes the buffer contents underneath me. for example, i might hit C-x C-s in the middle of editing a for ... { loop, and then everything below the left bracket get shifted right.

Describe the solution you'd like i would like to be able to turn off automatic re-formatting and, instead, have my formatting mistakes show up via flycheck (say).

Describe alternatives you've considered i guess, either live with it, or disable prettier-mode.

thanks for the tool!

jscheid commented 3 years ago

Sorry but that's not a feature I'm interested in adding at this time. You should be able to achieve this with eslint-plugin-prettier though. You can run eslint through flycheck.

You could also think about binding prettier-prettify to a key sequence of your choice. That way you can run it on demand rather than on file save. Perhaps that would feel less jarring to you. Good luck!

jscheid commented 3 years ago

Actually, on second thought I'll reopen this (only) for the suggestion to make formatting on save optional. You can simply disable the minor mode and you'll still be able to run prettier-prettify, but that way you don't get the other side benefits such as syncing of indentation settings.

greg-minshall commented 3 years ago

@jscheid thanks for the pointer to eslint-plugin-prettier. that works well for me. and, thanks again for prettier.el. cheers.

greg-minshall commented 3 years ago

sorry. finger-fumble. i didn't mean to close this.

mrcnski commented 3 years ago

I would also like this -- just a simple variable I could set to disable formatting on save. I have my Emacs save often: whenever the frame loses focus, whenever I run a shell command, etc. -- and as the OP said, it is annoying to have in-progress lines of code get clobbered. I would much rather only have it format when I press C-c n.

jscheid commented 2 years ago

This is available now, set prettier-prettify-on-save-flag via customization or any other way (perhaps buffer-local in a hook.)

I suppose removing the feature and letting users re-add it by setting their own before-save hook would have been more idiomatic, but I don't want to break the existing behavior at this point. Maybe in some future release.

greg-minshall commented 2 years ago

thank you.

mrcnski commented 2 years ago

Awesome, thanks!