From a545a58b6d1bfa4e3a2027e4eb9f60d7b3f2851f Mon Sep 17 00:00:00 2001 From: LDprg <71488985+LDprg@users.noreply.github.com> Date: Fri, 6 Dec 2024 23:10:48 +0100 Subject: [PATCH 1/5] Add zig --- internal/core/format.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/core/format.go b/internal/core/format.go index c3fd2beb..344a9029 100755 --- a/internal/core/format.go +++ b/internal/core/format.go @@ -53,6 +53,11 @@ var CommentsByNormedExt = map[string]map[string]string{ "blockStart": `(\{-.*)`, "blockEnd": `(.*-\})`, }, + ".zig": { + "inline": `(//.+)`, + "blockStart": `$^`, + "blockEnd": `$^`, + }, } // FormatByExtension associates a file extension with its "normed" extension @@ -89,6 +94,7 @@ var FormatByExtension = map[string][]string{ `\.(?:txt)$`: {".txt", "text"}, `\.(?:xml)$`: {".xml", "markup"}, `\.(?:yaml|yml)$`: {".yml", "code"}, + `\.(?:zig)$`: {".zig", "code"}, } // FormatFromExt takes a file extension and returns its [normExt, format] From 15d5e187e8d0ecfda40c67005794505b94b5c10e Mon Sep 17 00:00:00 2001 From: LDprg <71488985+LDprg@users.noreply.github.com> Date: Fri, 6 Dec 2024 23:15:35 +0100 Subject: [PATCH 2/5] Create test.zig --- testdata/fixtures/formats/test.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 testdata/fixtures/formats/test.zig diff --git a/testdata/fixtures/formats/test.zig b/testdata/fixtures/formats/test.zig new file mode 100644 index 00000000..396523bc --- /dev/null +++ b/testdata/fixtures/formats/test.zig @@ -0,0 +1,12 @@ +//! top-level doc-comment + +// normal comment + +/// doc-comment +const Timestamp = struct { + /// XXX: A comment in a struct + nanos: u32, + + /// TODO: Ad function + pub fn unixEpoch() Timestamp {} +}; From 86bc6f4ea480499f9f09799898a47931fc06e490 Mon Sep 17 00:00:00 2001 From: LDprg <71488985+LDprg@users.noreply.github.com> Date: Fri, 6 Dec 2024 23:18:31 +0100 Subject: [PATCH 3/5] Update lint.feature --- testdata/features/lint.feature | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/testdata/features/lint.feature b/testdata/features/lint.feature index 06b90ce0..2383c170 100755 --- a/testdata/features/lint.feature +++ b/testdata/features/lint.feature @@ -380,3 +380,11 @@ Feature: Lint test.mdx:46:3:vale.Annotations:'TODO' left in text """ And the exit status should be 0 + + Scenario: Lint a zig file + When I lint "test.zig" + Then the output should contain exactly: + """ + test.zig:7:9:vale.Annotations:'XXX' left in text + test.zig:10:9:vale.Annotations:'TODO' left in text + """ From 059665fd2b2fcbbac6cbb095dad1b17f42c7eece Mon Sep 17 00:00:00 2001 From: LDprg <71488985+LDprg@users.noreply.github.com> Date: Fri, 6 Dec 2024 23:32:49 +0100 Subject: [PATCH 4/5] Update format.go --- internal/core/format.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/core/format.go b/internal/core/format.go index 344a9029..e1d61154 100755 --- a/internal/core/format.go +++ b/internal/core/format.go @@ -54,7 +54,7 @@ var CommentsByNormedExt = map[string]map[string]string{ "blockEnd": `(.*-\})`, }, ".zig": { - "inline": `(//.+)`, + "inline": `(/{2,3}.+)`, "blockStart": `$^`, "blockEnd": `$^`, }, From 45dffb2f7881ff6f85bbad9d2b22303de67f4726 Mon Sep 17 00:00:00 2001 From: LDprg <71488985+LDprg@users.noreply.github.com> Date: Fri, 6 Dec 2024 23:34:17 +0100 Subject: [PATCH 5/5] Update format.go --- internal/core/format.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/core/format.go b/internal/core/format.go index e1d61154..b64b6764 100755 --- a/internal/core/format.go +++ b/internal/core/format.go @@ -54,7 +54,7 @@ var CommentsByNormedExt = map[string]map[string]string{ "blockEnd": `(.*-\})`, }, ".zig": { - "inline": `(/{2,3}.+)`, + "inline": `(/{2,3}.+)|(//!.+)`, "blockStart": `$^`, "blockEnd": `$^`, },