Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note

This purposely will ignore and not format auto generated files like main.c and all HAL files. This is okay and intentional. Dont manually format them.

To setup and run the clang format:

...

  1. Open VScode from any NER C project. You must do this once for every project!

  2. Open file-->preferences-->settings

  3. Make sure you are on “workspace” settings and not “user” settings

  4. Type clang in the settings search bar

  5. Change C_Cpp: Clang_format_fallback Style to none

    1. IF in Cerb, Shep, etc. Change C_Cpp: Clang_format_style to file:${workspaceRoot}/Drivers/Embedded-Base/clang-format

    2. IF in Embedded-Base: Change C_Cpp: Clang_format_style to file:${workspaceRoot}/clang-format

  6. Change editor.formatOnSave to true

...

  1. false

The linter will not run on save, and will have to be done with Ctr + Shft + i.


In CLI:

Debian based Linux/WSL:

Code Block
sudo apt-get install clang-format
clang-format -style=file:./Drivers/Embedded-Base/clang-format -i ./path/to/yourur/file.c -assume-filename=path/to/your/.clang-format

Windows:

IDK tbh why are you using CLI if you are on windows anyway

...

Mac:

Code Block
brew install clang-format
clang-format -style=file:./Drivers/Embedded-Base/clang-format -i ./path/to/yourur/file.c -assume-filename=path/to/your/.clang-format

(obviously use whatever package manager you want for Linux and Mac)

...