diff --git a/formatting-configs/.editorconfig b/formatting-configs/.editorconfig new file mode 100644 index 0000000..ee9f09c --- /dev/null +++ b/formatting-configs/.editorconfig @@ -0,0 +1,32 @@ +root = true + +[*] +charset = utf-8 +indent_style = tab +indent_size = 8 +tab_width = 8 +end_of_line = lf +insert_final_newline = true + +[*.{c,cc,cpp,h,hpp}] + +# Unbraced single-statement blocks +cpp_remove_braces_for_single_line_control_statements = true +resharper_cpp_remove_braces_for_single_statements = true +resharper_cpp_add_braces_for_single_line_if = false + +# Enforce BSD KNF for function bracess +cpp_new_line_before_open_brace_function = new_line +resharper_cpp_brace_style = next_line +resharper_cpp_function_definition_braces = next_line + +# Enforce K&R for everything else +cpp_new_line_before_open_brace_namespace = same_line +cpp_new_line_before_open_brace_type = same_line +cpp_new_line_before_open_brace_block = same_line +cpp_new_line_before_open_brace_lambda = same_line +cpp_new_line_before_else = false +cpp_new_line_before_catch = false +resharper_cpp_namespace_declaration_braces = end_of_line +resharper_cpp_type_declaration_braces = end_of_line +resharper_cpp_control_transfer_braces = end_of_line diff --git a/formatting-configs/clang-format.json b/formatting-configs/clang-format.json new file mode 100644 index 0000000..c8a42a4 --- /dev/null +++ b/formatting-configs/clang-format.json @@ -0,0 +1,19 @@ +{ + "BasedOnStyle": "LLVM", + "UseTab": "Always", + "IndentWidth": 8, + "TabWidth": 8, + "LineEnding": "LF", + "RemoveBracesLLVM": true, + "AlwaysBreakAfterReturnType": "AllDefinitions", + "BreakBeforeBraces": "Custom", + "BraceWrapping": { + "AfterFunction": true, + "AfterClass": false, + "AfterControlStatement": false, + "AfterNamespace": false, + "AfterStruct": false, + "BeforeElse": false, + "BeforeCatch": false + } +} diff --git a/formatting-configs/clang-format.yml b/formatting-configs/clang-format.yml new file mode 100644 index 0000000..11f5325 --- /dev/null +++ b/formatting-configs/clang-format.yml @@ -0,0 +1,20 @@ +# BSD KNF funcs + K&R blocks + other stuff +# Requires clang-format >=16 +BasedOnStyle: LLVM # defaults +UseTab: Always +IndentWidth: 8 +TabWidth: 8 +LineEnding: LF # unix + +RemoveBracesLLVM: true # single-statement blocks +AlwaysBreakAfterReturnType: AllDefinitions # KNF functions + +BreakBeforeBraces: Custom +BraceWrapping: + AfterFunction: true # KNF + AfterClass: false # K&R + AfterControlStatement: false # K&R + AfterNamespace: false # K&R + AfterStruct: false # K&R + BeforeElse: false # K&R + BeforeCatch: false # K&R