From a50abde3f39b545c1b59ae278997de7e75286c41 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Mon, 26 Oct 2020 17:27:06 +0100 Subject: [PATCH] Created clang-format (markdown) --- clang-format.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 clang-format.md diff --git a/clang-format.md b/clang-format.md new file mode 100644 index 0000000..018a9a6 --- /dev/null +++ b/clang-format.md @@ -0,0 +1,42 @@ +New code should be formatted according to .clang-format file before committing it in a pull request. ( https://clang.llvm.org/docs/ClangFormat.html ) + +It can be installed with `apt install clang-format` or `zypper in clang-tools` + + +## Checking XS files + +To also correct the formatting of XS files, configure clang-format to use the clang-format-xs wrapper like so +``` +git config clangformat.extensions c,h,xs +git config clangformat.binary $PWD/.github/workflows/clangformat/clang-format-xs +``` + +## Manual check after `git add` + +Use: +``` +git clang-format +``` + + +## Auto-check format on commit + +To ensure the clang-format formatting before committing, I found this tool: + +https://github.com/ailin-nemui/clang-format-hooks + +To use it, first clone the repo ( `git clone https://github.com/ailin-nemui/clang-format-hooks.git` ) + +Then, run the installer script inside your Irssi clone: + +``` +cd /path/to/src/irssi +../clang-format-hooks/git-pre-commit-format install +``` + +The next time you try to commit, the formatting will be checked! + + +## Emacs integration + +See [Emacs](Emacs)