webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
2.63k stars 157 forks source link

Add formatter config and workflows, format project #244

Closed ttytm closed 9 months ago

ttytm commented 9 months ago

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:

If any changes would further improve things for you let me know.

Example runs:

ttytm commented 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

Screenshot_20231008_035944

ttytm commented 9 months ago

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.

hassandraga commented 9 months ago

Formating on CI is better as we can not guarantee that all contributors have Clang installed.

ttytm commented 9 months ago

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.

hassandraga commented 9 months ago

I mean, whatever is easier and efficient we should do it. We can format PR manually.

hassandraga commented 9 months ago

I will use Clang to format code for my next PRs.