From 46d8275e7c4d461f84458c0c36c160f23c3daa30 Mon Sep 17 00:00:00 2001 From: Marius Eriksen Date: Tue, 11 Jan 2022 10:34:19 -0800 Subject: [PATCH 1/2] acmego: add clang-format for .cc, .cpp, .h --- acme/acmego/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/acme/acmego/main.go b/acme/acmego/main.go index 82567d8..2f9c25b 100644 --- a/acme/acmego/main.go +++ b/acme/acmego/main.go @@ -21,6 +21,7 @@ // The other known extensions and formatters are: // // .rs - rustfmt +// .cc, .cpp, .h - clang-format // package main @@ -47,7 +48,10 @@ var formatters = map[string][]string{ // Non-Go formatters (only loaded with -f option). var otherFormatters = map[string][]string{ - ".rs": []string{"rustfmt", "--emit", "stdout"}, + ".rs": []string{"rustfmt", "--emit", "stdout"}, + ".cpp": []string{"clang-format"}, + ".cc": []string{"clang-format"}, + ".h": []string{"clang-format"}, } func main() { From 3c967206894b9a5d7eaaa2c7ca13a52afc9f191a Mon Sep 17 00:00:00 2001 From: Marius Eriksen Date: Tue, 11 Jan 2022 10:51:55 -0800 Subject: [PATCH 2/2] add remainder of clang-format eligible extensions --- acme/acmego/main.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/acme/acmego/main.go b/acme/acmego/main.go index 2f9c25b..cb71262 100644 --- a/acme/acmego/main.go +++ b/acme/acmego/main.go @@ -21,7 +21,7 @@ // The other known extensions and formatters are: // // .rs - rustfmt -// .cc, .cpp, .h - clang-format +// .cpp, .c, .cc, .cu, .cxx, .h, .hh, .hpp, .hxx, .tcc, .mm, .m - clang-format // package main @@ -48,18 +48,25 @@ var formatters = map[string][]string{ // Non-Go formatters (only loaded with -f option). var otherFormatters = map[string][]string{ - ".rs": []string{"rustfmt", "--emit", "stdout"}, - ".cpp": []string{"clang-format"}, - ".cc": []string{"clang-format"}, - ".h": []string{"clang-format"}, + ".rs": []string{"rustfmt", "--emit", "stdout"}, } +// Clang formatters (only loaded with -f option). +var clangSuffixes = []string{ + ".cpp", ".c", ".cc", ".cu", ".cxx", ".h", ".hh", ".hpp", ".hxx", ".tcc", ".mm", ".m", +} + +var clangFormat = []string{"clang-format"} + func main() { flag.Parse() if *gofmt { for suffix, formatter := range otherFormatters { formatters[suffix] = formatter } + for _, suffix := range clangSuffixes { + formatters[suffix] = clangFormat + } } l, err := acme.Log() if err != nil {