From 462b3091fcdeca1fe99b3d334fcb43e8ff542624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20R=C3=B3=C5=BCewski?= Date: Thu, 25 Apr 2024 23:53:24 +0200 Subject: [PATCH] style: enhanced clarity coding style configs (#51) --- .clang-format | 31 +++++++++++++++++++++++++++++-- .editorconfig | 7 +++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/.clang-format b/.clang-format index 957f6f4..27d3d49 100644 --- a/.clang-format +++ b/.clang-format @@ -1,6 +1,9 @@ # Maintain consistent coding style across the entire project. -# This is a configuration file for clang-format. +# This is a configuration file for clang-format. The rules here are applied to all code in the +# entire project, including all the C++ example demo programs, and the main C demo project and +# library. The rules are still work in progress and subject to change. I still need to think +# about this. # C Language specifics. Language: Cpp @@ -13,6 +16,24 @@ ColumnLimit: 100 IndentWidth: 4 UseTab: Never +# Align consecutive assignments. +# const char *foo = "bar"; +# const int bar = 1; +# const double baz = 2.0; +AlignConsecutiveAssignments: true + +# Align consecutive declarations. +# const char *foo = "bar"; +# const int bar = 1; +# const double baz = 2.0; +AlignConsecutiveDeclarations: false + +# Align escaped newlines for the left. +AlignEscapedNewlinesLeft: true + +# Don't allow this rule. +AllowShortFunctionsOnASingleLine: false + # Braces to surrounding context. BraceWrapping: AfterClass: true @@ -26,5 +47,11 @@ BreakBeforeBraces: Custom # Update namespace comments. FixNamespaceComments: true -# These settings are the same as Python black. +# Align pointer to the right. +PointerAlignment: Right + +# Same as Black for Python. SpacesBeforeTrailingComments: 2 + +# Allow this rule. +SortIncludes: true diff --git a/.editorconfig b/.editorconfig index 925b017..1a22d7e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,9 +1,8 @@ # Maintain consistent coding style across the entire project. -# This is a configuration file for EditorConfig. - -# The settings for JavaScript, Python and C/C++ files are mirrored by language in .prettierrc, -# .eslintrc, .flake8, .pylintrc, pyproject.toml and .clang-format. Keep them in sync. +# This is a configuration file for EditorConfig. The settings for JavaScript, Python and C/C++ +# files are mirrored by languages in .prettierrc, .eslintrc, .flake8, .pylintrc, pyproject.toml and +# .clang-format files that is shared accros all my codebase projects. Keep them in sync. root = true