prettier / prettier-emacs

Minor mode to format JS code on file save
http://jlongster.com/A-Prettier-Formatter
372 stars 53 forks source link

Requires `diff` on Windows #25

Open kraai opened 6 years ago

kraai commented 6 years ago

When I installed prettier-emacs on Windows and saved a file with an incorrect style, the saved file still had the incorrect style. I did not see an error message displayed on the last line of the window. When I checked the contents of the *Messages* buffer, however, I saw that there was an error trying to run diff:

Saving file c:/Users/mkraai/src/calculator/online/server.js...
Wrote c:/Users/mkraai/AppData/Local/Temp/1/prettier9292Lab.js
Error: (file-error "Searching for program" "No such file or directory" "diff")
Wrote c:/Users/mkraai/src/calculator/online/server.js

Once I installed the MSYS version of diff, added the MSYS bin directory to my path, and restarted Emacs, the style was corrected when I saved the file.

I'm not sure how to fix this. Here are some possibilities:

ryanolsonx commented 6 years ago

I would love if we were able to get rid of the diff dependency. Something I love about using emacs on Windows is that lisp "just works". When I used to use vim, I'd have to worry a lot about external commands and making sure they're installed.

Maybe there's a diff implementation in elisp that could be leveraged.

nickmccurdy commented 6 years ago

Could the diff function in diff.el be used?

Also as a temporary workaround, I think there's a port of GNU diff on Chocolatey.

tgroshon commented 6 years ago

Using @nickmccurdy suggesting to choco install diffutils solved the problem for me. It would be great if we didn't have to install that OR we could just update the docs and say that Windows users should do that.

rcoedo commented 6 years ago

@tgroshon do you mind doing a PR with the updated README?

thanks!

tgroshon commented 6 years ago

Absolutely. I will post one today.

Kethku commented 5 years ago

Any update on this? I am running into prettier emacs issues as well

tgroshon commented 5 years ago

Can't believe I forgot to make a PR for that README.md change 🤦‍♂️ Just made one! The basic steps are as follows:

  1. Install Chocolatey: https://chocolatey.org/install
  2. Open an Admin Powershell session
  3. Install the diff program: choco install diffutils