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

Update Config to have a single field alignment option #2114

Closed
eureka-cpu opened this issue Jun 25, 2022 · 2 comments · Fixed by #2153
Closed

Update Config to have a single field alignment option #2114

eureka-cpu opened this issue Jun 25, 2022 · 2 comments · Fixed by #2153

Comments

@eureka-cpu
Copy link
Contributor

This could look like:

pub struct Structures {
    /// Align fields of user defined structures to a threshold.
    pub field_alignment: FieldAlignment,
    /// Put small struct literals on a single line.
    pub struct_lit_single_line: bool,
}

pub enum FieldAlignment {
    AlignFields(usize),
    Off,
}

This would reduce the clutter in Config, remove the need for extra constants and take away the need for the user to input the same number for each type of alignment.

@kayagokalp
Copy link
Member

Hmm, that looks good but in doing so wouldn't we block people from selecting which type to align (with different thresholds)? For example, would there be a case where a user wants to align enums and structs but not storage fields?

@eureka-cpu
Copy link
Contributor Author

One thing mentioned before is that we don't want to make swayfmt "fully customizable" like rustfmt. I don't really see a user in the future that would want one aligned but not the other, but if those users do arise it's an easy fix. In the mean time it makes the use case much clearer and cleaner in the code itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants