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

Indentation seems to be inconsistent with Elm example code #71

Closed
yupferris opened this issue May 11, 2016 · 2 comments
Closed

Indentation seems to be inconsistent with Elm example code #71

yupferris opened this issue May 11, 2016 · 2 comments

Comments

@yupferris
Copy link

yupferris commented May 11, 2016

First off, let me say I really like the cycles-based indentation approach used by elm-mode. I've used a similar one in haskell-mode before, and it works really nicely with this kind of language (in fact haskell-mode renders _'s underneath the various levels in the cycle as well, which would be nice to have in this mode as well, but I digress...) :)

However, it seems the indentation level is a bit inconsistent with all of the Elm example code I see elsewhere. It seems that most example code just uses two spaces for an indentation "level", yet the various levels in the cycles provided by this plugin seem more arbitrary.

For example, here's a simple main definition in one of my projects, indented by hand to match what I believe is the standard with Elm example code:

main =
  App.program
    { init = init
    , update = update
    , subscriptions = \_ -> Sub.none
    , view = view
    }

However, when I use the levels provided by this mode, it looks like this:

main =
  App.program
       { init = init
       , update = update
       , subscriptions = \_ -> Sub.none
       , view = view
       }

Notice the extra spaces in the record value lines. The only options for indentation the mode provides in the first record line (starting with {) are either no indentation, or the indentation shown above. Before inserting the { character, it gives me either no indentation or the position directly under the . from the line above, which is also wrong (3 spaces from the line above instead of 2). This is just one example, but the problem seems to manifest in many places and in many different ways.

Is there a specific reason this style was chosen? It appears to be inconsistent with both other Elm code I see around, and also what haskell-mode does (though I may be wrong).

@Bogdanp
Copy link
Collaborator

Bogdanp commented May 23, 2016

The issues and inconsistencies you see are mostly due lack of time on my part to spend on fixing and improving the indentation code. Contributions in this area are very much welcome :D.

That being said, I just pushed a couple of changes that should make the indentation more consistent with how elm-format formats code and I believe this issue is fixed (although the default indent offset is now 4 (set elm-indent-offset to 2 if you want 2-space indentation)). Let me know if you run into any other issues!

@Bogdanp Bogdanp closed this as completed May 23, 2016
@yupferris
Copy link
Author

You're a champion, thanks :D

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

2 participants