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

Make import sorting/aligning optional #914

Closed
ivan-m opened this issue Oct 5, 2015 · 7 comments · Fixed by #1003
Closed

Make import sorting/aligning optional #914

ivan-m opened this issue Oct 5, 2015 · 7 comments · Fixed by #1003

Comments

@ivan-m
Copy link
Contributor

ivan-m commented Oct 5, 2015

I use stylish-haskell to sort and align my imports; it's thus visually confusing when I add an import, haskell-mode sorts and aligns it (undoing some of the layout that stylish-haskell does), and then as soon as I save the layout changes again.

@gracjan
Copy link
Contributor

gracjan commented Oct 6, 2015

What function does the sorting?

@ivan-m
Copy link
Contributor Author

ivan-m commented Oct 6, 2015

haskell-add-import calls haskell-sort-imports and haskell-align-imports.

@gracjan
Copy link
Contributor

gracjan commented Oct 6, 2015

Ah, I see. It should:

  1. Find out if current import list is sorted.
  2. If so keep the sorting order.
  3. Otherwise just add import at the end of the list.

That way we can get away without a setting with a 'just works!' functionality. Somebody needs to implement the 'is sorted' function.

@ivan-m
Copy link
Contributor Author

ivan-m commented Oct 6, 2015

I see what you mean about having a "just works!" functionality, but then that will also require being able to adapt to current aligning strategy, etc.

I think it would be much easier to just have a setting. Maybe even (ab)use haskell-stylish-on-save and assume that stylish-haskell will do a sort/align.

@gracjan
Copy link
Contributor

gracjan commented Oct 6, 2015

Customization options present a usability challenge. They are a testing nightmare and require users to discover the option even exists.

@ivan-m
Copy link
Contributor Author

ivan-m commented Oct 6, 2015

Did you see my update? (I did an edit of my previous comment right after I posted it.)

This of course assumes that the stylish-haskell config doesn't have imports -> align -> none (I think that covers sorting as well).

The other possible solution - and why I see the noticeable changes - is that the sorting and aligning in haskell-mode doesn't seem to have anything similar to stylish-haskell's group option; I'm not sure if this could be done automagically in haskell-mode unless you tried to detect whether the various import blocks are already indented or not.

@gracjan
Copy link
Contributor

gracjan commented Oct 6, 2015

If we can use preexisting option then I'm okay with it.

bergey added a commit to bergey/haskell-mode that referenced this issue Nov 26, 2015
If `haskell-stylish-on-save` is set, assume that stylish-haskell is
handling import alignment & sorting.  Therefore, do not align and sort
after inserting a new import with `haskell-add-import`.

Add documentation explaining this to both `haskell-stylish-on-save` and
`haskell-add-import`.

closes haskell#914
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

Successfully merging a pull request may close this issue.

2 participants