From 25b28aa8877faafde9f1770f4afccab95d681d43 Mon Sep 17 00:00:00 2001 From: Adam Scott Date: Fri, 25 Oct 2024 14:41:58 -0400 Subject: [PATCH] Add .clang-format-glsl check --- .pre-commit-config.yaml | 13 +++++++++- misc/utility/.clang-format-glsl | 42 +++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 misc/utility/.clang-format-glsl diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 572eaf67912..29263f07ee3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: rev: v19.1.0 hooks: - id: clang-format - files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|m|mm|inc|java|glsl)$ + files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|m|mm|inc|java)$ types_or: [text] exclude: | (?x)^( @@ -20,6 +20,17 @@ repos: platform/android/java/editor/src/main/java/com/android/.*| platform/android/java/lib/src/com/.* ) + - id: clang-format + name: clang-format-glsl + files: \.(glsl)$ + types_or: [text] + exclude: | + (?x)^( + tests/python_build/.*| + platform/android/java/editor/src/main/java/com/android/.*| + platform/android/java/lib/src/com/.* + ) + args: ["-style=file:misc/utility/.clang-format-glsl"] - repo: https://github.com/pocc/pre-commit-hooks rev: v1.3.5 diff --git a/misc/utility/.clang-format-glsl b/misc/utility/.clang-format-glsl new file mode 100644 index 00000000000..59efa8fa353 --- /dev/null +++ b/misc/utility/.clang-format-glsl @@ -0,0 +1,42 @@ +# GLSL-specific rules. +# The rules should be the same as .clang-format, except those explicitly mentioned. +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignOperands: DontAlign +AlignTrailingComments: + Kind: Never + OverEmptyLines: 0 +AllowAllParametersOfDeclarationOnNextLine: false +BreakConstructorInitializers: AfterColon +ColumnLimit: 0 +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 +Cpp11BracedListStyle: false +IncludeCategories: + - Regex: ^".*"$ + Priority: 1 + - Regex: ^<.*\.h>$ + Priority: 2 + - Regex: ^<.*>$ + Priority: 3 +IndentCaseLabels: true +IndentWidth: 4 +JavaImportGroups: + - org.godotengine + - android + - androidx + - com.android + - com.google + - java + - javax +KeepEmptyLinesAtTheStartOfBlocks: false +ObjCBlockIndentWidth: 4 +PackConstructorInitializers: NextLine +RemoveSemicolon: false # Differs from base .clang-format +SpacesInLineCommentPrefix: + Minimum: 0 + Maximum: -1 +Standard: c++20 +TabWidth: 4 +UseTab: Always