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

Luau Type Unioning should support Multi-Line formating #531

Closed
nightcycle opened this issue Aug 12, 2022 · 1 comment · Fixed by #536
Closed

Luau Type Unioning should support Multi-Line formating #531

nightcycle opened this issue Aug 12, 2022 · 1 comment · Fixed by #536
Labels
bug Something isn't working

Comments

@nightcycle
Copy link

nightcycle commented Aug 12, 2022

``I recently began using StyLua and love how it's made my functions more readable by moving the parameters to multiple lines when there are too many of them. I believe it should do the same for unioned types, as currently is fits them all into a single line, making it fairly unreadable. Here's an example from a recent project of mine using custom types.

Current StyLua format:

type PseudoEnumItemConstructor =
	(((GuiThemeTypeEnum, string) -> GuiThemeType) & ((GuiBrandTypeEnum, string) -> GuiBrandType) & ((GuiStateModifierEnum, string) -> GuiStateModifier) & ((GuiBrandTypeEnum, string) -> GuiBrandType) & ((GuiStateModifierEnum, string) -> GuiStateModifier) & ((GuiDensityModifierEnum, string) -> GuiDensityModifier) & ((GuiColorPaletteEnum, string) -> GuiColorPalette) & ((GuiTypographyEnum, string) -> GuiTypography) & ((GuiColorTypeEnum, string) -> GuiColorType) & ((ValidityFailTypeEnum, string) -> ValidityFailType) & ((VehicleClassEnum, string) -> VehicleClass) & ((VehiclePurposeEnum, string) -> VehiclePurpose) & ((FuelTypeEnum, string) -> FuelType) & ((LaneTypeEnum, string) -> LaneType) & ((InfrastructureTypeEnum, string) -> InfrastructureType) & ((FoundationTypeEnum, string) -> FoundationType) & ((BiomeTypeEnum, string) -> BiomeType) & ((BuildStateEnum, string) -> BuildState) & ((BuildMethodTypeEnum, string) -> BuildMethodType) & ((CurvePartTypeEnum, string) -> CurvePartType))

Proposed StyLua format:

type PseudoEnumItemConstructor = (
	((GuiThemeTypeEnum, string) -> GuiThemeType) 
	& ((GuiBrandTypeEnum, string) -> GuiBrandType) 
	& ((GuiStateModifierEnum, string) -> GuiStateModifier) 
	& ((GuiBrandTypeEnum, string) -> GuiBrandType) 
	& ((GuiStateModifierEnum, string) -> GuiStateModifier) 
	& ((GuiDensityModifierEnum, string) -> GuiDensityModifier) 
	& ((GuiColorPaletteEnum, string) -> GuiColorPalette) 
	& ((GuiTypographyEnum, string) -> GuiTypography) 
	& ((GuiColorTypeEnum, string) -> GuiColorType) 
	& ((ValidityFailTypeEnum, string) -> ValidityFailType) 
	& ((VehicleClassEnum, string) -> VehicleClass) 
	& ((VehiclePurposeEnum, string) -> VehiclePurpose) 
	& ((FuelTypeEnum, string) -> FuelType) 
	& ((LaneTypeEnum, string) -> LaneType) 
	& ((InfrastructureTypeEnum, string) -> InfrastructureType) 
	& ((FoundationTypeEnum, string) -> FoundationType) 
	& ((BiomeTypeEnum, string) -> BiomeType) 
	& ((BuildStateEnum, string) -> BuildState) 
	& ((BuildMethodTypeEnum, string) -> BuildMethodType) 
	& ((CurvePartTypeEnum, string) -> CurvePartType)
)

Thank you for your time!

@JohnnyMorganz JohnnyMorganz added the bug Something isn't working label Aug 14, 2022
@JohnnyMorganz
Copy link
Owner

I think it isn't formatting because the whole thing is wrapped within parentheses. Removing them and it should format multiline.

Stylua should be handling these parentheses though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants