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

Keep :require sorted #2002

Closed
wilkerlucio opened this issue Jun 14, 2018 · 3 comments
Closed

Keep :require sorted #2002

wilkerlucio opened this issue Jun 14, 2018 · 3 comments
Labels
new Marks issues describing new features released Marks issues which have had the fixes released in a stable build
Milestone

Comments

@wilkerlucio
Copy link

When importing new namespaces Cursive always add it to the end of the list.

I think would be interested if Cursive could make it sorted, forcing sorting all the times could be bad, but Cursive could detect if the requires are already sorted, and if they are, insert the new require in the correct place so it keeps sorted.

The algorithm could be something like:

(if (= current-requires (sort current-requires))
  (-> (add-require current-requires new-require) sort)
  (add-require new-require))

This would greatly help to keep the requires clean.

@conan
Copy link

conan commented Sep 18, 2019

I like this idea, but would prefer to have the option of forcing sorting at all times as well (we generally never use the nested require syntax).

Relates to #77 and #1197 and #1592 and #1975

@Sardtok
Copy link

Sardtok commented Feb 17, 2022

For Java there's the Optimize imports command. I would have liked it to be the same for Clojure. There is configuration for Optimize imports, and it can be set to automatically optimize imports. This enforces specific ordering (lexicographically, but you can add exceptions to the sorting for specific packages to create groups).

The more complex functionality isn't such a big deal, but being able to sort namespaces using a shortcut, or automatically on save, would be great. Right now I use Emacs to do this with a before-save-hook to automatically sort requires on saving.

@cursive-ide
Copy link
Owner

@Sardtok This has actually been implemented as an extension to the Optimise Imports command in the latest EAP series. See the 1.12.2 EAP series announcements on the mailing list: https://groups.google.com/forum/#!forum/cursive.

I'm planning to implement what Wilker suggests here as an improvement to the current single-namespace add, however, which is why this issue isn't closed yet.

@cursive-ide cursive-ide added this to the 1.12.2 milestone Feb 17, 2022
@cursive-ide cursive-ide modified the milestones: 1.12.2, 1.12.3 Apr 13, 2022
@cursive-ide cursive-ide modified the milestones: 1.12.3, 1.12.4 Apr 25, 2022
@cursive-ide cursive-ide modified the milestones: 1.12.4, 1.12.5 Jun 3, 2022
@cursive-ide cursive-ide modified the milestones: 1.12.5, 1.12.5-eap1 Aug 3, 2022
@cursive-ide cursive-ide added the new Marks issues describing new features label Aug 3, 2022
@cursive-ide cursive-ide added the released Marks issues which have had the fixes released in a stable build label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new Marks issues describing new features released Marks issues which have had the fixes released in a stable build
Projects
None yet
Development

No branches or pull requests

4 participants