diff --git a/internal/core/format.go b/internal/core/format.go index c3fd2beb..b64b6764 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": `(/{2,3}.+)|(//!.+)`, + "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] 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 + """ 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 {} +};