Task-Tracker-Systems / Task-Tracker-Device

Sources for a task time recording device.
https://task-tracker-systems.github.io/Task-Tracker-Device/
MIT License
2 stars 0 forks source link

Add and apply style configuration for code formatter Clang-Format. #11

Closed dhebbeker closed 1 year ago

dhebbeker commented 1 year ago

Style is based on style 'Microsoft' which has the greatest resemblance with Allman indentation style, from the available predefined styles.

The style configuration can be applied by clang-format (part of LLVM) using common IDE's. For example Microsoft Visual Studio Code and Eclipse CDT support to invoke clang-format with a configurable style configuration file.

To format all files using a UNIX shell, this line can be used:

find . -iname '*.h' -o  -iname '*.hpp' -o -iname '*.c' -o -iname '*.cpp' -o -iname '*.ino' | xargs clang-format -i --style=file --fallback-style=none --verbose

Also this adds a GitHub Action which does automatically check if the style format is matched.

FiveTeethless commented 1 year ago

btw. I found a VSCode extension that lets you format your current open file in according to the .clang-format specs with only a keybord shortcut: Ctrl + Alt + F grafik It basically overrides the builtin formatter with the clang-format call. Clang-Format

dhebbeker commented 1 year ago

Nice! For me it worked already "out of the box", as I had the C/C++ Extension already installed. The default settings use the style configuration file already.

https://code.visualstudio.com/docs/cpp/cpp-ide https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools