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

Allow reading from stdin #46

Closed
ehamberg opened this issue Jul 7, 2020 · 7 comments · Fixed by #50
Closed

Allow reading from stdin #46

ehamberg opened this issue Jul 7, 2020 · 7 comments · Fixed by #50
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ehamberg
Copy link

ehamberg commented Jul 7, 2020

It would be great if erlfmt supported reading from stdin (e.g. when passed --stdin) so that it can be used by editor plugins such as https://github.com/lassik/emacs-format-all-the-code that pass a buffer's content to the formatter instead of operating on a file on disk.

@awalterschulze awalterschulze added the good first issue Good for newcomers label Jul 7, 2020
@awalterschulze
Copy link
Member

This is a great idea :) We will look into adding it.

@awalterschulze awalterschulze added the enhancement New feature or request label Jul 7, 2020
@awalterschulze
Copy link
Member

This feature is being added in #50

Thanks again for the great idea :)

@ehamberg
Copy link
Author

ehamberg commented Jul 9, 2020

Thank you so much! Works great!

In case any doom emacs users stumble over this issue: You can now use erlfmt to format erlang buffers by adding the following to config.el:

(set-formatter! 'erlfmt  "erlfmt -" :modes '(erlang-mode))

@awalterschulze
Copy link
Member

Happy to hear it works so well :)

Maybe we should make even easier to spot this tip.
#55

@Benjamin-Philip
Copy link

Thank you so much! Works great!

In case any doom emacs users stumble over this issue: You can now use erlfmt to format erlang buffers by adding the following to config.el:

(set-formatter! 'erlfmt  "erlfmt -" :modes '(erlang-mode))

This does not seem to work with rebar3:

 (set-formatter! 'erlfmt  "rebar3 fmt -" :modes '(erlang-mode))

Could you update your comment to what you use now, incase there has been some change to set-formatter!?

@ehamberg
Copy link
Author

Could you update your comment to what you use now, incase there has been some change to set-formatter!?

I still use the same config. However, I don't use erlfmt through rebar3, I call it directly. Not sure if rebar3 fmt supports reading from stdin.

@michalmuskala
Copy link
Member

Even if reading from stdin with rebar3 worked fine, I think outputting to stdout might actually not - rebar3 output is quite verbose and sometimes quite random if things go to stdout or stderr. With standalone escript we can control it all, but running as a rebar3 plugin this is more complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants