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

Configure and run automatic Lua code styling #1931

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

alerque
Copy link
Member

@alerque alerque commented Dec 13, 2023

I've looked into this before but the available Lua code formatters have always been sub-par and running them on this project has always run into edge cases that create errors and need manual intervention. Hence I've avoided it.

But the more I use Rust with rustfmt and Python with ruff --format and just don't have to think about code formatting the more I like it. I had another look at Lua and there are now two viable options. The one I'm primarily targeting here is stylua, but there is also an attempt to configure the Lua LSP which runs EmmyLuaCodeStyle to format similarly. For now the canonical style will be what StyLua outputs.

I'm not 100% happy with the output and have some upstream issues opened about fixing it, but the fact that we can already run it out of the box and still get a 100% working project back out of it in very little time means I'll probably be headed this way soon.

I'm not in a hurry to merge this to master, but probably will land it in conjunction with merging develop (#1904) prior to releasing v0.15.0.

The good news for existing PRs and future contributors is that because it works 100%, updating existing PRs to match and avoid merge conflicts is one command away.

@alerque alerque added the todo label Dec 13, 2023
@alerque alerque added this to the v0.15.0 milestone Dec 13, 2023
@alerque
Copy link
Member Author

alerque commented Jan 10, 2024

I will probably (but not certainly) be holding off on this for this feature upstream. I expect it to get added eventually, and when it does my strong preference for the space will mean a little bit of churn as everything gets reformatted again. It probably shouldn't be a blocker considering how nice it would be to get 100% deterministic formatting, but yes that's why I'm (probably) holding off on this.

@alerque alerque modified the milestones: v0.15.0, v0.15.1 Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant