Skip to content

Commit 9de8234

Browse files
unhappychoiceclaude
andcommitted
feat: add Zig language definition
- Add Zig language struct with .zig extension support - Register Zig in all_languages() list - Implement comment node validation for Zig 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1a9345e commit 9de8234

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

src/domain/models/language.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::domain::models::languages::{
22
CSharp, Cpp, Dart, Go, Haskell, Java, JavaScript, Kotlin, Php, Python, Ruby, Rust, Scala,
3-
Swift, TypeScript, C,
3+
Swift, TypeScript, Zig, C,
44
};
55
use crate::presentation::ui::Colors;
66
use std::hash::{Hash, Hasher};
@@ -72,6 +72,7 @@ impl Languages {
7272
Box::new(Haskell),
7373
Box::new(Dart),
7474
Box::new(Scala),
75+
Box::new(Zig),
7576
]
7677
}
7778

src/domain/models/languages/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub mod rust;
1414
pub mod scala;
1515
pub mod swift;
1616
pub mod typescript;
17+
pub mod zig;
1718

1819
pub use c::C;
1920
pub use cpp::Cpp;
@@ -31,3 +32,4 @@ pub use rust::Rust;
3132
pub use scala::Scala;
3233
pub use swift::Swift;
3334
pub use typescript::TypeScript;
35+
pub use zig::Zig;

src/domain/models/languages/zig.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use crate::domain::models::Language;
2+
use crate::presentation::ui::Colors;
3+
use std::hash::Hash;
4+
5+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
6+
pub struct Zig;
7+
8+
impl Language for Zig {
9+
fn name(&self) -> &'static str {
10+
"zig"
11+
}
12+
fn extensions(&self) -> Vec<&'static str> {
13+
vec!["zig"]
14+
}
15+
16+
fn color(&self) -> ratatui::style::Color {
17+
Colors::lang_zig()
18+
}
19+
20+
fn display_name(&self) -> &'static str {
21+
"Zig"
22+
}
23+
24+
fn is_valid_comment_node(&self, node: tree_sitter::Node) -> bool {
25+
let node_kind = node.kind();
26+
node_kind == "comment"
27+
}
28+
}

0 commit comments

Comments
 (0)