Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: zig support #930

Open
wants to merge 5 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/core/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
8 changes: 8 additions & 0 deletions testdata/features/lint.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
12 changes: 12 additions & 0 deletions testdata/fixtures/formats/test.zig
Original file line number Diff line number Diff line change
@@ -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 {}
};