From eebd26c88f3737845746025e09e51b8fd46bedcd Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sun, 20 Oct 2024 19:33:06 -0600 Subject: wip clang-format --- .clang-format | 40 ++++++++++++++++++++++++++++++++++++++++ .editorconfig | 5 +++++ .yamlfmt.yml | 41 +++++++++++++++++++++++++++++++++++++++++ Makefile | 10 +++++++--- 4 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 .clang-format create mode 100644 .yamlfmt.yml diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..d0c759b --- /dev/null +++ b/.clang-format @@ -0,0 +1,40 @@ +--- +# .clang-format - How to format C files in sbc-harness +# +# Copyright (C) 2024 Luke T. Shumaker +# SPDX-Licence-Identifier: AGPL-3.0-or-later + +Language: Cpp + +LineEnding: LF + +# Indentation +UseTab: ForContinuationAndIndentation +TabWidth: 8 +IndentWidth: 8 +ContinuationIndentWidth: 8 +ColumnLimit: 80 +IndentCaseLabels: false + +# Brace style +AllowShortIfStatementsOnASingleLine: false +BreakBeforeBraces: Attach + +# Alignment +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + +# Preprocessor +SortIncludes: CaseSensitive +PPIndentWidth: -1 # inherit from IndentWidth +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: true + AcrossComments: false +AlignEscapedNewlines: Left diff --git a/.editorconfig b/.editorconfig index 2aa13e7..362e1bb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -39,6 +39,11 @@ _mode = bash [{lib9p/idl.gen,lib9p/include/lib9p/linux-errno.h.gen}] _mode = python3 +[{*.yml,.clang-format}] +_mode = yaml +indent_style = space +indent_size = 4 + [{.editorconfig,.gitmodules}] _mode = ini diff --git a/.yamlfmt.yml b/.yamlfmt.yml new file mode 100644 index 0000000..67a341d --- /dev/null +++ b/.yamlfmt.yml @@ -0,0 +1,41 @@ +--- +# .yamlfmt.yml - How to format YAML files in sbc-harness +# +# Copyright (C) 2024 Luke T. Shumaker +# SPDX-Licence-Identifier: AGPL-3.0-or-later + +# Format options +formatter: + type: basic + # Newlines + line_ending: lf + eof_newline: true + retain_line_breaks: false + retain_line_breaks_single: true + scan_folded_as_literal: false + # Indentation + indent: 4 + indentless_arrays: false + # Other whitespace + pad_line_comments: 1 + trim_trailing_whitespace: true + # Other + include_document_start: true + disallow_anchors: true + drop_merge_tag: false + max_line_length: 70 + +# Program operation +continue_on_error: false +output_format: default + +# Which files to process +doublestar: false +exclude: [] +include: [] +gitignore_excludes: false +gitignore_path: .gitignore +regex_exclude: [] +extensions: + - yaml + - yml diff --git a/Makefile b/Makefile index d0c5c78..b4931b0 100644 --- a/Makefile +++ b/Makefile @@ -76,7 +76,9 @@ lint/python3: lint/%: black --check $(sources_$*) isort --check $(sources_$*) lint/c: lint/%: - @: TODO + clang-format --dry-run -Werror -- $(sources_$*) +lint/yaml: lint/%: + yamlfmt -lint $(sources_$*) lint/make lint/cmake lint/gitignore lint/ini lint/9p lint/markdown: lint/%: @: lint/unknown: lint/%: @@ -89,7 +91,7 @@ lint/all: lint/%: if ! grep -q 'Copyright (C) 2024 Luke T. Shumaker' $$filename; then \ echo "$$filename is missing a copyright statement"; r=1; continue; \ fi; \ - dscname=$$(sed -n '1,3{ /^#!/d; /^