Closed ttytm closed 9 months ago
Microsoft is a space nazi when there is no config that says otherwise. Here is where you can configure tab width on github to use what you like best for viewing code in the browser: https://github.com/settings/appearance
Currently the lint assumed that clangd installed used locally, then all common editors could take care of formatting via format on save or running a format command.
I didn't integrated formatting and writing to the repository if formatting is off. We can do it if that's preferred.
Formating on CI is better as we can not guarantee that all contributors have Clang installed.
Okay, I see that automated writing of formatting changes can make sense in our case. I'll look into it.
Though it is a valid requirement for contribution to meet a projects code style. And it's not guaranteed for most formatters unless a formatter is built into the language itself. Alternatively, a contributor could format manually to satisfy linting for now before a PR is merged if the linter is not happy.
I mean, whatever is easier and efficient we should do it. We can format PR manually.
I will use Clang to format code for my next PRs.
Adds changes mentioned in: https://github.com/webui-dev/webui/discussions/242
I think the settings resemble the current style fairly well.
A style I couldn't find a matching setting for is to indent everything in pre-processor directives. Adding
IndentPPDirectives: BeforeHash
to.clang-format
would come closest, but variable declarations still wouldn't be indent, resulting in:Uniform indent without decls:
Not uniform indent for decls:
So I left the setting out to use the default / more commonly used style of not indenting pre-processor directives. The used sections for the directives are usually highlighted by the editor if an lsp is running:
If any changes would further improve things for you let me know.
Example runs: