diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-20 19:33:06 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-20 20:27:33 -0600 |
commit | eebd26c88f3737845746025e09e51b8fd46bedcd (patch) | |
tree | 1aa30ea8ac6d9f750b49548f79626b0fe4060ba3 | |
parent | 318162fdf1ff86297afcce334f61d2d6ff5e3345 (diff) |
wip clang-formatclang-format
-rw-r--r-- | .clang-format | 40 | ||||
-rw-r--r-- | .editorconfig | 5 | ||||
-rw-r--r-- | .yamlfmt.yml | 41 | ||||
-rw-r--r-- | Makefile | 10 |
4 files changed, 93 insertions, 3 deletions
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 <lukeshu@lukeshu.com> +# 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 <lukeshu@lukeshu.com> +# 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 @@ -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; /^<!--$$/d; /-\*- .* -\*-/d; s,[/*# ]*,,; s/ - .*//;p; q; }' $$filename); \ + dscname=$$(sed -En '1,3{ /^#!|^<!--$$|-\*- .* -\*-|^---$$/d; s,[/*# ]*,,; s/ - .*//;p; q; }' $$filename); \ filename_alt1=$$(echo "$$filename" | sed \ -e 's,^cmd/,,' \ -e 's,.*/include/,,' \ @@ -112,7 +114,9 @@ format/python3: format/%: format/sh format/bash: format/% @: format/c: format/%: - @: TODO + clang-format -i -- $(sources_$*) +format/yaml: format/%: + yamlfmt $(sources_$*) format/make format/cmake format/gitignore format/ini format/9p format/markdown: format/%: @: format/unknown: format/%: |