.clang-format 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. # References:
  2. # https://clang.llvm.org/docs/ClangFormatStyleOptions.html
  3. # https://code.qt.io/cgit/qt/qt5.git/tree/_clang-format
  4. BasedOnStyle: LLVM
  5. Standard: c++17
  6. # 指针和引用的对齐方式。
  7. # 可能的值有:
  8. # PAS_Left (在配置中: Left) 指针左对齐。
  9. # PAS_Right (在配置中: Right) 指针右对齐。
  10. # PAS_Middle (在配置中: Middle) 指针中间对齐。
  11. PointerAlignment: Right
  12. # public/protected/private 等访问修饰符偏移量
  13. AccessModifierOffset: -4
  14. # 缩进长度
  15. IndentWidth: 4
  16. # 连续空行的最大数
  17. MaxEmptyLinesToKeep: 999
  18. # 在OC中的@property后面添加一个空格。例如:使用“@property (readonly)”而不是“@property(readonly)”
  19. ObjCSpaceAfterProperty: true
  20. # OC块中所拍的字符数
  21. ObjCBlockIndentWidth: 4
  22. # 取决于值, 语句“int f() { return 0; }”可以被放到一个单行。
  23. # 可能的值有:
  24. # SFS_None (在配置中: None) 从不合并方法或函数到单独的一行。
  25. # SFS_Empty (在配置中: Empty) 仅合并空的函数。
  26. # SFS_Inline (在配置中: Inline) 仅合并类中定义的方法或函数. 意味着 “empty”.
  27. # SFS_All (在配置中: All) 合并所有的方法适应单行.
  28. AllowShortFunctionsOnASingleLine: None
  29. # 如果为真(true), 语句“if (a) return;” 能被放到单行。
  30. AllowShortIfStatementsOnASingleLine: false
  31. # 如果为真(true), 对齐注释。
  32. AlignTrailingComments: true
  33. # 如果为真,对齐连续的宏定义
  34. AlignConsecutiveMacros: true
  35. # 如果为真(true),将会在“[”之后和“]”之前插入空格。
  36. SpacesInSquareBrackets: false
  37. # 如果为真(true), 将会在“(”之后和“)”之前插入空格。
  38. SpacesInParentheses : false
  39. # 如果为真(true), 校准连续的声明。
  40. # 这将会校准连续多行的声明的名字。这将会导致像下面这样的格式:
  41. # int aaaa = 12;
  42. # float b = 23;
  43. # std::string ccc = 23;
  44. AlignConsecutiveDeclarations: false
  45. # 如果为真(true),连续调整多行
  46. # 这将会调整连续行中的分配操作符。这将会导致像下面这样的格式:
  47. # int aaaa = 12;
  48. # int b = 23;
  49. # int ccc = 23;
  50. AlignConsecutiveAssignments: false
  51. # 如果为假(false),移除分配操作符(=)前空格。
  52. SpaceBeforeAssignmentOperators: true
  53. # 如果为真(true), 将会在字面量容器中插入空格(例如 OC和Javascript的数组和字典字面量)。
  54. SpacesInContainerLiterals: false
  55. # 缩进case标签
  56. IndentCaseLabels: true
  57. # 如果表达式中包含函数调用,并且函数调用因为表达式太长被放到了下一行,是否缩进
  58. IndentWrappedFunctionNames: true
  59. # 如果为真(true), 保持块的起始空行。
  60. # true: false:
  61. # if (foo) { vs. if (foo) {
  62. # bar();
  63. # bar(); }
  64. # }
  65. KeepEmptyLinesAtTheStartOfBlocks: true
  66. # 允许所有参数都被放在下一行
  67. AllowAllParametersOfDeclarationOnNextLine: false
  68. # 使用C风格强制类型转换后,是否在中间添加一个空格
  69. SpaceAfterCStyleCast: true
  70. # 在模板定义后换行
  71. AlwaysBreakTemplateDeclarations: Yes
  72. # Tab长度
  73. TabWidth: 4
  74. # 是否使用Tab
  75. UseTab: Never
  76. # 在括号后对齐参数
  77. # someLongFunction(argument1,
  78. # argument2);
  79. AlignAfterOpenBracket: Align
  80. # 名字空间内部缩进
  81. NamespaceIndentation: All
  82. # 一行最长列数
  83. ColumnLimit: 100
  84. # 按层次缩进宏定义
  85. IndentPPDirectives: AfterHash
  86. # 预处理语句缩进为 2
  87. PPIndentWidth: 2
  88. # 数组元素对齐
  89. AlignArrayOfStructures: Left
  90. # 不对头文件排序
  91. SortIncludes: Never
  92. FixNamespaceComments: false
  93. StatementMacros: ['__qas_attr__', '__qas_exclude__', '__qas_include__']
  94. ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]