As a Roblox developer, it is currently too hard to style code automatically, or use formatting. Especially if you generate code using assistant, but in general, having stylua enforced across all of Studio would be an excellent option for Roblox.
If Roblox is able to address this issue, it would improve my development experience because we could have a unified toolchain and styling solution for all of Roblox.
This takes away freedom from creators. As much as I love stylua and have plenty of experience using it over 10+ repositories holding Rojo instances, It would only serve to confuse and dilute the experience for new creators who aren’t sure why their code keeps getting reformatted.
I don’t believe it’s feasible to implement this without changing the development experience or studio workflow for all creators. A worthy alternative could be including these settings within the script tab in studio as a toggle, within place settings or as a script flag (similar to --!strict.)
While I do think this is a good idea, There is no way to implement this with the direction roblox is going and always has gone involving creators and the sheer freedom of how people can develop on roblox.
Hot take, but I dislike stylua. There are a lot of things it does well, but the things I disagree with are forced unless I write --stylua: ignore before every damn statement that it applies to.
If I intend to have something formatted a specific way, I need it to be something I can control at a project-wide level instead of having to edge-case every single damn thing.
In particular there are two things that make stylua a major PITA for me:
A lot of the time it’s inappropriate to force an if-then-else statement to be on a single line if the entire line is more than like 30-40 characters long.
Metatable prototype definitions should be written like this:
export type Class = typeof(setmetatable({} :: {
Field: string
}, Module))
instead of:
export type Class = typeof(setmetatable(
{} :: {
Field: string
},
Module
))
This one might be more subjective, and it does clash with Roblox’s style guide. But I feel there should be less emphasis on the syntax around the metatable type, and more emphasis on the typecast. I should NOT be forced to use the former.
This is completely the wrong way to go about it - in fact - we shouldn’t be saying anything near this.
Ideally, the goal is to provide developers a way to define their own stylistic parameters so that their codebases adhere to their own style and preferences. That is optimistically where we want to be and that is what we should have. Not implementing an external reformatting tool as a half-measure for this overarching problem.
I like stylua; But I hate stylua at the same time. It makes my life a whole lot easier, and in addition to having that metatable thing making me go about janky-er ways of defining my classes, guard clauses, my lord and savior, get extended to three lines when they could otherwise be one. More than that, I have save on window focus lost for VSC and it overwrites some of the formatting I was preparring (primarily empty functions I was about to write), and being an unmedicated ADHD-haver that makes it hard to keep focus.
I would also like to see a meaningful code formatter in studio - often I copy scripts into an external editor just to run a formatter (stylua) on them and then copy them back into studio.
I don’t think any of the concerns in the replies here about developer freedom / enforced styling are valid at all - this could work as a replacement for studio’s existing formatter which doesn’t do a whole lot and already requires developer interaction to run. I also don’t think we should delay improving the formatter in favor of a perfect customizable solution.
I’d love to see a proper code formatter in Studio, but I don’t think StyLua is the correct choice. Studio shouldn’t depend on a tool that reimplements Luau parsing and can often be left without support for new Luau syntax for weeks at a time. Instead, Luau should ship its own configurable and code formatter.
Bob will stand over your shoulder staring at your code at all times. If you dare deviate from what Bob wants your code to look like, Bob will physically push you away from the keyboard and correct it. You have no choice but to surrender your free will to Bob. Even if your deviations are minor and 100% reasonable, opinionated solutions are the best solutions.
I think this is a bit disingenuous - the thrust of the feature request is about enabling developers to enforce style on their codebase, not about forcing all developers to do so.
I would personally rephrase it to ask for a more meaningful studio formatter and the ability to auto-run it on all scripts, but the sense is the same.
I don’t think it should be forcefully applied to all Roblox Developers, it would be better off if anything, or if Roblox could internally build it in themselves, that it would be applied as a setting to something like Beta Features, or just as a Studio setting. But yeah, agreeing with @Maximum_ADHD on this one - you shouldn’t be forced into programming in a certain way, this should just be something for those that actually would make use of StyLua.