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

Elm-format as prettier plugin? #459

Closed
kachkaev opened this issue Feb 13, 2018 · 7 comments
Closed

Elm-format as prettier plugin? #459

kachkaev opened this issue Feb 13, 2018 · 7 comments

Comments

@kachkaev
Copy link

kachkaev commented Feb 13, 2018

TL;DR: The plugin is here https://github.com/gicentre/prettier-plugin-elm

Hi everyone 👋

I became interested in formatting ```elm code blocks inside markdown files and my first approach to this was to tweak atom-beautify: Glavin001/atom-beautify#1990. The PR is still waiting to be merged, but I'm generally happy with the solution locally even despite two issues described in #65 (comment).

Unfortunately, the tool I've got is Atom-specific and only works when Remark is chosen as a beautifier for markdown (which is not so by default). Of course, the situation is far from a zero-config command-line heaven or from supporting other editors like VSCode 😅

I recently noticed that Prettier (a fast-growing opinionated code formatter) added plugin support. Potentially, that's great news for the Elm community, because it seems like it is now possible to access elm-format via unified Prettier API from anywhere. In addition to that, the docs mention something called embed, which possibly means that elm-format can be applied to markdown code blocks that start with ```elm 🎉

I'm opening this issue because I have not yet found an npm package called prettier-plugin-elm and would like to help with putting it together. Sorry that it's not as relevant to elm-format as other issues, but perhaps this repo is still the best place to start a discussion. There is a chance that I might find some time on implementing a prototype in the next several weeks, but I'd be keen to see a bit of support from experienced members of the Elm community.

Who would like to join? What do you think of this idea in general?

@ohanhi
Copy link

ohanhi commented Feb 13, 2018

From what I can tell, Prettier plugins need to be JavaScript. elm-format is written in Haskell. I don't know if you can somehow write a middle layer that could make the elm-format binary to work as a Prettier plugin parser, but surely it would not be easy. I'm not saying it's not a good idea, just that it might not be as straightforward as one might think.

@kachkaev
Copy link
Author

Thanks for your comment @ohanhi, you're right!

I just discovered https://discourse.elm-lang.org/ and am tending to move this discussion there. Will share a link once I'm done.

@kachkaev
Copy link
Author

kachkaev commented Feb 13, 2018

@avh4
Copy link
Owner

avh4 commented Feb 14, 2018

FYI, I am interested in making elm-format available as a javascript package, likely using ghcjs like what https://ellie-app.com has done for elm-compiler. If anyone is interested in working on that, please coordinate with me.

@Glavin001
Copy link

@kachkaev : I am developing Unibeautify (complete rewrite of Atom-Beautify) with the intention of becoming a universal code beautifier. This sounds like what you're looking for.

Unfortunately, the tool I've got is Atom-specific and only works when Remark is chosen as a beautifier for markdown (which is not so by default). Of course, the situation is far from a zero-config command-line heaven or from supporting other editors like VSCode 😅

I recently noticed that Prettier (a fast-growing opinionated code formatter) added plugin support.

Unibeautify will eventually have both Atom (rewrite of Atom-Beautify ) and VSCode (New extension: https://github.com/Unibeautify/vscode ) support. And potentially others, too, like Sublime Text ( https://github.com/Unibeautify/unibeautify-sublime ).

Unibeautify's beautifiers are similar to Atom-Beautify's design. Take a look at https://github.com/Unibeautify/beautifier-prettier and https://github.com/Unibeautify/beautifier-prettydiff and others at https://github.com/Unibeautify for example. If you are interested in adding ELM Format support to Unibeautify please let us know! /cc @szeck87

@kachkaev
Copy link
Author

If anyone is interested in an integration of elm-format into Prettier, see
https://github.com/gicentre/prettier-plugin-elm 🎉

Feedback is welcome!

@kachkaev
Copy link
Author

Follow-up PR: #574

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

4 participants