style: add template formatting and hygiene config

This commit is contained in:
tqcq
2026-05-18 09:40:52 +08:00
parent b375ff9e29
commit 3128d8d117
6 changed files with 152 additions and 3 deletions
+47 -1
View File
@@ -1,2 +1,48 @@
---
Language: Cpp
BasedOnStyle: Microsoft
BasedOnStyle: Google
Standard: c++17
ColumnLimit: 120
UseTab: Never
IndentWidth: 4
ContinuationIndentWidth: 4
NamespaceIndentation: None
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: Never
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
PointerAlignment: Left
ReferenceAlignment: Left
AlwaysBreakAfterReturnType: All
AlwaysBreakAfterDefinitionReturnType: All
SortIncludes: CaseSensitive
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^".*\.h"$'
Priority: 1
- Regex: '^".*"$'
Priority: 2
- Regex: '^<([a-z_]+\.h)>$'
Priority: 3
- Regex: '^<([a-z0-9_]+)>$'
Priority: 4
- Regex: '^<(gtest|gmock|benchmark|fmt|spdlog|nlohmann|httplib)/.*>$'
Priority: 5
- Regex: '^<(sys|linux|arpa|netinet|unistd|pthread)/.*>$'
Priority: 6
- Regex: '^<.*>$'
Priority: 7
+17
View File
@@ -0,0 +1,17 @@
---
Checks: >
-*,
bugprone-*,-bugprone-reserved-identifier,-bugprone-easily-swappable-parameters,
clang-analyzer-*,
misc-*,-misc-const-correctness,-misc-include-cleaner,-misc-unused-parameters,-misc-use-anonymous-namespace,
modernize-*,-modernize-use-trailing-return-type,-modernize-deprecated-headers,-modernize-use-nullptr,
performance-*,
portability-*,
readability-*,-readability-identifier-naming,-readability-identifier-length,-readability-implicit-bool-conversion,-readability-function-cognitive-complexity,-readability-function-size
WarningsAsErrors: '*'
HeaderFilterRegex: '^(src|examples)/.*'
CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: '25'
- key: readability-function-size.LineThreshold
value: '120'
+19
View File
@@ -0,0 +1,19 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
max_line_length = 120
[*.{md,markdown}]
trim_trailing_whitespace = false
[*.{yml,yaml,json,json5,jsonc}]
indent_size = 2
[Makefile]
indent_style = tab
+20
View File
@@ -0,0 +1,20 @@
* text=auto eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
*.patch text eol=lf diff
*.diff text eol=lf diff
3rd/patches/** text eol=lf diff
*.tar.gz -text -diff
*.tgz -text -diff
*.zip -text -diff
*.gz -text -diff
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.pdf binary
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -eu
script_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
repo_root=$(git -C "$script_dir/.." rev-parse --show-toplevel 2>/dev/null)
cd "$repo_root"
exec python3 scripts/pre_commit.py "$@"
+41 -2
View File
@@ -1,3 +1,42 @@
# Build directories and generated CMake output
/build/
/build-*/
/cmake-build-*/
/out/
CMakeFiles/
CMakeCache.txt
cmake_install.cmake
CTestTestfile.cmake
DartConfiguration.tcl
Testing/
install_manifest.txt
compile_commands.json
.cache
build/
CMakeUserPresets.json
# Python caches
__pycache__/
*.py[cod]
*$py.class
.pytest_cache/
.mypy_cache/
.ruff_cache/
.pyright/
# Local tooling and transient output
.cache/
.codegraph/
.oc-whiteboard/
.opencode/
*.log
*.tmp
*.temp
.tmp/
tmp/
temp/
# Keep vendored inputs trackable for the reusable offline template
!3rd/
!3rd/archives/
!3rd/archives/*.tar.gz
!3rd/patches/
!3rd/patches/**