Provide stylua.toml with explicit formatting conventions
seflue opened this issue ยท 6 comments
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.
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.
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.
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).
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 ๐
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 ๐ ).
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.