Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update clang-format file for include grouping #326

Open
bmario opened this issue Mar 14, 2024 · 3 comments
Open

Update clang-format file for include grouping #326

bmario opened this issue Mar 14, 2024 · 3 comments

Comments

@bmario
Copy link
Member

bmario commented Mar 14, 2024

We decided to order includes in the following format:

<main file header>

<lo2s group>

<cpp dependencies group>

<std lib group>

<cstr lib group>

extern "C" {
<c dependencies>
}

It's possible to explain that to clang-format:

@bmario
Copy link
Member Author

bmario commented Mar 14, 2024

We need https://clang.llvm.org/docs/ClangFormatStyleOptions.html#mainincludechar

Which is Part of clang format 19 ...

@bmario
Copy link
Member Author

bmario commented Mar 14, 2024

With clang-format-19 this works. With older versions it doesn't.

MainIncludeChar: Any
IncludeBlocks: Regroup
IncludeCategories:
  - Regex: '^<lo2s/'
    Priority: 2
  - Regex: '(hpp|hxx)>$'
    Priority: 3
  - Regex: '^<([^c][[:alnum:]|_]+|chrono|compare|charconv|complex|condition_variable|codecvt|coroutine|concepts)>$'
    Priority: 4 
  - Regex: '^<c[[:alnum:]|_]+>'
    Priority: 5
  - Regex: '\.h>'
    Priority: 6

@tilsche
Copy link
Member

tilsche commented Apr 25, 2024

clang-format 19 is not yet released. So we do have to wait a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants