Skip to content

clang-format config #774

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
# Nuklear clang-format config. For more info see
# https://clang.llvm.org/docs/ClangFormat.html
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html

# llvm docs recommend using Cpp for C and C++
Language: Cpp

#AlignAfterOpenBracket: DontAlign
AlignArrayOfStructures: Right
AlignConsecutiveAssignments:
Enabled: true
AcrossComments: false
AcrossEmptyLines: false
AlignCompound: true
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossComments: false
AcrossEmptyLines: false
AlignCompound: true
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossComments: false
AcrossEmptyLines: false
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossComments: true
AcrossEmptyLines: true
AlignCaseColons: false
AlignEscapedNewlines: Left
AlignOperands: AlignAfterOperator
AlignTrailingComments: Always
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: All
BraceWrapping:
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterStruct: false
AfterUnion: false
BeforeElse: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
BreakAdjacentStringLiterals: false
BreakBeforeBinaryOperators: true
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakStringLiterals: true
# 160 is arbitrary, if set to 0 will cause some short enums to be split on multiple lines
ColumnLimit: 160
ContinuationIndentWidth: 4
DerivePointerAlignment: true
ForEachMacros: [nk_foreach]
IndentCaseLabels: true
IndentGotoLabels: false
# Not perfect but does improve readability
IndentPPDirectives: AfterHash
IndentWidth: 4
LineEnding: LF
# docs show ReflowComments is type "ReflowCommentsStyle" but when run with clang-format (v19.1.7) gives "invalid boolean" error
ReflowComments: false
SortIncludes: Never
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false

...
# This file is avaliable under either the MIT License or public domain. See LICENSE for more info.
2 changes: 1 addition & 1 deletion src/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def fix_comments(str):
# print("\n#ifndef " + macro + "_SINGLE_HEADER");
# print("#define " + macro + "_SINGLE_HEADER");
print("#ifndef NK_SINGLE_FILE");
print(" #define NK_SINGLE_FILE");
print("# define NK_SINGLE_FILE");
print("#endif");
print("");

Expand Down
2 changes: 2 additions & 0 deletions src/clang_format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
clang-format --style=file:../.clang-format -i nuklear.h nuklear_internal.h nuklear_math.c nuklear_util.c nuklear_color.c nuklear_utf8.c nuklear_buffer.c nuklear_string.c nuklear_draw.c nuklear_vertex.c nuklear_font.c nuklear_input.c nuklear_style.c nuklear_context.c nuklear_pool.c nuklear_page_element.c nuklear_table.c nuklear_panel.c nuklear_window.c nuklear_popup.c nuklear_contextual.c nuklear_menu.c nuklear_layout.c nuklear_tree.c nuklear_group.c nuklear_list_view.c nuklear_widget.c nuklear_text.c nuklear_image.c nuklear_9slice.c nuklear_button.c nuklear_toggle.c nuklear_selectable.c nuklear_slider.c nuklear_knob.c nuklear_progress.c nuklear_scrollbar.c nuklear_text_editor.c nuklear_edit.c nuklear_property.c nuklear_chart.c nuklear_color_picker.c nuklear_combo.c nuklear_tooltip.c