avh4 / elm-format

elm-format formats Elm source code according to a standard set of rules based on the official Elm Style Guide
BSD 3-Clause "New" or "Revised" License
1.31k stars 147 forks source link

[draft] guidelines for "elm-format approved" IDE integrations #104

Open avh4 opened 8 years ago

avh4 commented 8 years ago

This is a draft of guidelines for IDEs and IDE plugins that want to officially integrate with elm-format.

The goal of elm-format is to make it as easy as possible to follow a standard, consistent style so that everyone can get the benefit of code that is easier to write, easier to read, and easier to maintain.

An "elm-format approved" plugin does the following:

An "elm-format approved" IDE comes with an "elm-format approved" plugin installed and enabled, or otherwise provides all the features of an "elm-format approved" plugin.

Bogdanp commented 8 years ago

The default behavior should be to format any *.elm files on save when working on an Elm project.

I think this should be opt in behavior rather than the default.

avh4 commented 8 years ago

@Bogdanp Can you elaborate on why you think it should be opt-in? The goal for elm-format is to make it as easy as possible for people to follow the Elm style guide.

Bogdanp commented 8 years ago

I should have done that in my original comment :). Here are a few bullet points:

Re the first point, how will elm-format deal with any syntax changes to the language in 0.17 (assuming there will be such changes)? Will all elm-format users be forced to upgrade?

avh4 commented 8 years ago

I updated the draft to hopefully clarify that if elm-format is not found, then the plugin doesn't need to constantly show error messages on save.

The 1.0 release is not going to be until a while after Elm 0.17 is released, so there won't be a stable release that supports Elm 0.16. But in the future, there will be separate elm-format versions for each Elm version. (For example, you will install one of elm-format-0.17-1.0.0 or elm-format-0.18-1.0.0 depending on which version of Elm you are using.) The only difference between those two elm-format versions will be which Elm syntax version is the default--both binaries will support both Elm versions, and there will be a --elm-version command line arg to override the default if desired. A plugin could either depend on the user to instal the correct elm-format version, or try to detect the Elm version and pass the command line argument.

simax commented 8 years ago

I've installed elm-format on windows 10 as described in the readme and checked the format on save option.

If I open a file in atom and change the format so its incorrect then hit save, nothing changes. I've also set show error notifications on save and I get a message elm-format exited with code null. So elm-format is being called. However, the file is not reformatted.

If I run elm-format from the command line the file is formatted correctly (I can see it get "refreshed" in atom) so elm-format exists on the path.

I've set the binary path in the package settings to the location I downloaded and installed elm-format. Which I added to the path.

Any idea why it works correctly from the command line but not from within atom?

Rolograaf commented 8 years ago

@simax Does Ctrl-shift-B format the file? Do you have beautify?

simax commented 8 years ago

@Rolograaf Looks like I didn't have atom-beautify or at least I didn't have Beautify On Save checked in the Elm setting.

Working great now, thanks for the help.

benjick commented 7 years ago

In atom-elm-format we're always formatting the buffer (using --stdin) and not the file. We're also saving the cursor position. Would that qualify for a green checkmark under "formatting"? :)