feat: add Zig syntax highlighting
This commit is contained in:
+18
-3
@@ -74,6 +74,13 @@ static MD_HIGHLIGHTS: LazyLock<String> = LazyLock::new(|| {
|
||||
.join("\n")
|
||||
});
|
||||
|
||||
// Upstream's Lua patterns are regex-compatible; spell-check metadata is not a color.
|
||||
static ZIG_HIGHLIGHTS: LazyLock<String> = LazyLock::new(|| {
|
||||
tree_sitter_zig::HIGHLIGHTS_QUERY
|
||||
.replace("#lua-match?", "#match?")
|
||||
.replace(" @spell", "")
|
||||
});
|
||||
|
||||
// The MIT-licensed upstream C++ crate bundles, but does not export, injections.scm.
|
||||
// This minimal AST query uses its raw-string delimiter/content nodes:
|
||||
// https://github.com/tree-sitter/tree-sitter-cpp/blob/v0.23.4/queries/injections.scm
|
||||
@@ -111,7 +118,7 @@ fn spec(
|
||||
}
|
||||
}
|
||||
|
||||
static LANGUAGES: LazyLock<[LanguageSpec; 18]> = LazyLock::new(|| {
|
||||
static LANGUAGES: LazyLock<[LanguageSpec; 19]> = LazyLock::new(|| {
|
||||
[
|
||||
spec(
|
||||
super::RUST_ID,
|
||||
@@ -257,6 +264,14 @@ static LANGUAGES: LazyLock<[LanguageSpec; 18]> = LazyLock::new(|| {
|
||||
tree_sitter_md::INJECTION_QUERY_INLINE,
|
||||
"",
|
||||
),
|
||||
spec(
|
||||
"zig",
|
||||
"Zig",
|
||||
tree_sitter_zig::LANGUAGE.into(),
|
||||
ZIG_HIGHLIGHTS.as_str(),
|
||||
tree_sitter_zig::INJECTIONS_QUERY,
|
||||
"",
|
||||
),
|
||||
]
|
||||
});
|
||||
|
||||
@@ -349,6 +364,7 @@ fn detect_path(path: &Path) -> Option<&'static LanguageSpec> {
|
||||
"cc" | "cpp" | "cxx" | "c++" | "hh" | "hpp" | "hxx" | "h++" | "ipp" | "inl"
|
||||
| "tpp" => "C++",
|
||||
"go" => "Go",
|
||||
"zig" => "Zig",
|
||||
_ => return None,
|
||||
}
|
||||
}
|
||||
@@ -396,8 +412,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn selected_files_and_auxiliary_grammars_are_registered() {
|
||||
assert_eq!(all().count(), 18);
|
||||
assert!(all().all(|spec| !spec.highlights.is_empty()));
|
||||
for (filename, language) in [
|
||||
("main.rs", "Rust"),
|
||||
("Gemfile", "Ruby"),
|
||||
@@ -417,6 +431,7 @@ mod tests {
|
||||
("main.cpp", "C++"),
|
||||
("main.C", "C++"),
|
||||
("main.go", "Go"),
|
||||
("main.zig", "Zig"),
|
||||
] {
|
||||
assert_eq!(
|
||||
detect(Some(Path::new(filename)), None).map(|spec| spec.name),
|
||||
|
||||
Reference in New Issue
Block a user