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

Provide stylua.toml with explicit formatting conventions #43

Closed
seflue opened this issue May 30, 2024 · 6 comments
Closed

Provide stylua.toml with explicit formatting conventions #43

seflue opened this issue May 30, 2024 · 6 comments
Labels
question Further information is requested

Comments

@seflue
Copy link
Collaborator

seflue commented May 30, 2024

When I tried to make some changes to the code, I realized, that my formatter settings are not compatible with the projects one, it reformats all the code. To make it easy to contribute, it would be very beneficial to provide these settings as a stylua.toml.

@chipsenkbeil
Copy link
Owner

chipsenkbeil commented May 30, 2024

I've never used stylua. I think the only formatting that happens is provided by the Lua language server's defaults. Could look into providing that file when I have time to look into more details about it. 😄

[EDIT]
I think the LuaLS/lua-language-server uses https://github.com/CppCXY/EmmyLuaCodeStyle.

It seems like sylua uses Roblox's style guide per JohnnyMorganz/StyLua#693.

Not sure if there's a template stylua file that matches the EmmyLuaCodeStyle format.

[EDIT2]

Alternatively, we just switch the style to use stylua. I don't have a preference on style at the moment, so happy to have a PR that reformats all Lua files to a a stylua if that's the best formatter these days. Would mean I'd need to figure out how to turn off the language server formatter.

@seflue
Copy link
Collaborator Author

seflue commented May 30, 2024

I just did some research. I think, the best way is to provide a .editorconfig which is configured in a way, that stylua and lua-language-server format it exactly in the same way. Then it would not matter, if the individual developer is just using the formatting feature from lua-language-server or stylua via none-ls.
I will continue to research to find some common ground between the current formatting, stylua and EmmyLuaCodeStyle.

@seflue
Copy link
Collaborator Author

seflue commented May 30, 2024

There is also a Github Action and pre-commit-hook for stylua.

What setup would you prefer? Adding a pre-commit hook or just relying that a developer would use either stylua or lua-language-server for formatting? We could add the stylua GH action to the pipeline just to check. That's what nvim-orgmode does. We could also reformat and autocommit in the CI pipeline. Personally I'm a bit undecided, but I think I would prefer the check and the pre-commit hook.

We could also provide both, a stylua.toml and an .editorconfig (like nvim-orgmode).

@chipsenkbeil
Copy link
Owner

What setup would you prefer?

Personally, I like having there be a failure if your PR doesn't match expected formatting, rather than doing the formatting for you. So I'd rely on someone to use stylua or the lua language server to do the formatting, or just hand-format based on the error messages from a github action.

Also, if nvim-orgmode has a stylua, we could just follow that one and do a big reformat of the plugin to follow it. I really don't mind which way we go 😄

@seflue seflue mentioned this issue May 31, 2024
@seflue
Copy link
Collaborator Author

seflue commented May 31, 2024

I created a PR: #44. Please give me a sign, that you commited/merged all your intermediate code changes, than I will do the reformatting and the branch can be merged. I just want to avoid big merge conflicts with ongoing changes on your side (I just know the pain 😅).

@chipsenkbeil
Copy link
Owner

I created a PR: #44. Please give me a sign, that you commited/merged all your intermediate code changes, than I will do the reformatting and the branch can be merged. I just want to avoid big merge conflicts with ongoing changes on your side (I just know the pain 😅).

Now active commits or branches on my side. You're good to go.

@seflue seflue closed this as completed May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants