sway icon indicating copy to clipboard operation
sway copied to clipboard

The formatter should alphabetize `use` statements if they're not separated by an empty line

Open mohammadfawaz opened this issue 3 years ago • 3 comments

We already alphabetize items within a single use statements. It would be nice to also alphabetize the use statements themselves if they're not separated by an empty line. This replicates the behavior of the Rust formatter.

cc @eureka-cpu couldn't find an open issue for this but please close it if it's already tracked somewhere else!

mohammadfawaz avatar Jul 05 '22 13:07 mohammadfawaz

This will be included in the ItemUse::format() functionality !

eureka-cpu avatar Jul 05 '22 21:07 eureka-cpu

This will be included in the ItemUse::format() functionality !

Since the deadline is approaching I've unassigned for the time being since I will be working on finishing out the basic features. If someone picks it up by all means! if not I will continue once the MVP is finished.

eureka-cpu avatar Aug 18 '22 00:08 eureka-cpu

To be clear, it currently does sort alphabetically just in the scope of each use statement and not as a group of use statements.

eureka-cpu avatar Aug 18 '22 00:08 eureka-cpu

@cr-fuel to do this you'll need to add some extra logic to separate the use statements into individual blocks to be formatted with what is already there. You'll need to collect the use statements first, by looking ahead for the next use statement. If it finds there are two consecutive newlines, only then you should format the previous block.

eureka-cpu avatar Sep 19 '23 20:09 eureka-cpu