I am using vim-autoformat
, which uses clang-format
as external formatter.
It seems that clang-format
won't indent the C++ #pragma
. For example:
#include <omp.h>
#include <cstdio>
int main()
{
#pragma omp parallel for
for (int i = 0; i < 10; ++i)
{
puts("demo");
}
return 0;
}
I would like to have it formatted into :
#include <omp.h>
#include <cstdio>
int main()
{
#pragma omp parallel for
for (int i = 0; i < 10; ++i)
{
puts("demo");
}
return 0;
}
I checked clangformat, but didn't find which option I could use.
It's been late but this is the solution you are looking for. It formats the pragma along with the code block.
https://github.com/MedicineYeh/p-clang-format
The main concept is replacing the string so that the formatter uses the "correct" rules on these pragmas. The motivative example is as following.