Skip to content

Commit

Permalink
[lint] Add clang-format rule for header sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Mar 14, 2024
1 parent ae73135 commit d709d34
Showing 1 changed file with 66 additions and 8 deletions.
74 changes: 66 additions & 8 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,72 @@ ForEachMacros: [ foreach, Q_FOREACH ]
# Sort headers by main include file (implicit priority 0),
# then project and private includes, then system headers
IncludeCategories:
- Regex: '^<([a-z|_]+)>' # standard library headers
Priority: 1
- Regex: '^(<[A-z]+)' # dependency headers
Priority: 2
- Regex: '^(<|")dart/' # DART headers
Priority: 3
- Regex: '^".*' # headers relative to this project
Priority: 4
- Regex: '^".*\.h(pp)?"$' # headers relative to this project
Priority: 1

# DART headers
- Regex: '^<dart\/config.hpp>$'
Priority: 10
- Regex: '^<dart\/test\/.*\.h(pp)?>$'
Priority: 20
- Regex: '^<dart\/python\/.*\.h(pp)?>$'
Priority: 21
- Regex: '^<dart\/gui\/.*\.h(pp)?>$'
Priority: 22
- Regex: '^<dart\/utils\/.*\.h(pp)?>$'
Priority: 23
- Regex: '^<dart\/simulation\/.*\.h(pp)?>$'
Priority: 24
- Regex: '^<dart\/constraint\/.*\.h(pp)?>$'
Priority: 25
- Regex: '^<dart\/collision\/.*\.h(pp)?>$'
Priority: 26
- Regex: '^<dart\/dynamics\/.*\.h(pp)?>$'
Priority: 27
- Regex: '^<dart\/optimizer\/.*\.h(pp)?>$'
Priority: 28
- Regex: '^<dart\/lcpsolver\/.*\.h(pp)?>$'
Priority: 29
- Regex: '^<dart\/integration\/.*\.h(pp)?>$'
Priority: 30
- Regex: '^<dart\/math\/.*\.h(pp)?>$'
Priority: 31
- Regex: '^<dart\/common\/.*\.h(pp)?>$'
Priority: 32
- Regex: '^<dart\/.*\.h(pp)?>$'
Priority: 33
- Regex: '^<dart\/external\/.*\.h(pp)?>$'
Priority: 34

# 3rd-party headers
- Regex: '^<.*\.h(pp)?>$'
Priority: 50
- Regex: '^<.*\/.*>$'
Priority: 50

# C++ standard library headers, then C
# TODO(JS): Add when new C++ STL header begins with "c" is found
- Regex: "^<charconv>$"
Priority: 100
- Regex: "^<chrono>$"
Priority: 100
- Regex: "^<compare>$"
Priority: 100
- Regex: "^<complex>$"
Priority: 100
- Regex: "^<concepts>$"
Priority: 100
- Regex: "^<condition_variable>$"
Priority: 100
- Regex: "^<coroutine>$"
Priority: 100
- Regex: "^<c.*>$" # C standard library headers
Priority: 110
- Regex: "^<([a-z|_]+)>$"
Priority: 100

- Regex: ".*"
Priority: 999
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentFunctionDeclarationAfterType: false
Expand Down

0 comments on commit d709d34

Please sign in to comment.