Skip to content

Commit 92535ce

Browse files
authored
feat: add Clojure language support (#311)
* Add Clojure language support with proper type classification * Support for def (Variable), ns (Namespace), defn/defmacro/defn- (Function) * Support for deftype/defrecord (Class) and defprotocol (Interface) * Comprehensive tests and documentation Co-authored-by: DanRioDev <DanRioDev@users.noreply.github.com>
1 parent 90e7366 commit 92535ce

File tree

41 files changed

+1547
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1547
-6
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ tree-sitter-java = "0.23"
4242
tree-sitter-php = "0.24"
4343
tree-sitter-c-sharp = "0.23"
4444
tree-sitter-c = "0.24"
45+
tree-sitter-clojure = "0.1"
4546
tree-sitter-cpp = "0.23"
4647
tree-sitter-haskell = "0.23"
4748
tree-sitter-dart = "0.0.4"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
## Features ✨
1414

15-
- 🦀🐍⚡🐹💎🍎🎯☕🐘#️⃣🔧➕🎭🎯⚡ **Multi-language**: Rust, TypeScript, JavaScript, Python, Go, Ruby, Swift, Kotlin, Java, PHP, C#, C, C++, Haskell, Dart, Scala, Zig (more languages incoming!)
15+
- 🦀🐍⚡🐹💎🍎🎯☕🐘#️⃣🔧➕🎭🎯⚡ **Multi-language**: Rust, TypeScript, JavaScript, Python, Go, Ruby, Swift, Kotlin, Java, PHP, C#, C, C++, Haskell, Dart, Scala, Clojure, Zig (more languages incoming!)
1616
- 📊 **Real-time metrics**: Live WPM, accuracy, and consistency tracking as you type
1717
- 🏆 **Ranking system**: Unlock developer titles from "Hello World Newbie" to "Quantum Computer" with ASCII art
1818
- 🎮 **Multiple game modes**: Normal, Time Attack, and custom difficulty levels (Easy to Zen)

assets/languages/lang_ascii.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
"lang_haskell": "magenta",
1717
"lang_dart": "cyan",
1818
"lang_zig": "yellow",
19+
"lang_clojure": "green",
1920
"lang_default": "white"
2021
}

assets/languages/lang_dark.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
"lang_haskell": {"r": 94, "g": 80, "b": 134},
1717
"lang_dart": {"r": 0, "g": 180, "b": 240},
1818
"lang_zig": {"r": 249, "g": 169, "b": 60},
19+
"lang_clojure": {"r": 92, "g": 181, "b": 68},
1920
"lang_default": {"r": 255, "g": 255, "b": 255}
2021
}

assets/languages/lang_light.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
"lang_haskell": {"r": 94, "g": 80, "b": 134},
1717
"lang_dart": {"r": 0, "g": 120, "b": 180},
1818
"lang_zig": {"r": 189, "g": 99, "b": 0},
19+
"lang_clojure": {"r": 92, "g": 181, "b": 68},
1920
"lang_default": {"r": 64, "g": 64, "b": 64}
2021
}

docs/supported-languages.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
| C | `.c`, `.h` | - | `tree_sitter_c` |
88
| C# | `.cs`, `.csx` | `cs`, `c#` | `tree_sitter_c_sharp` |
99
| C++ | `.cpp`, `.cc`, `.cxx`, `.hpp` | `c++` | `tree_sitter_cpp` |
10+
| Clojure | `.clj`, `.cljs`, `.cljc` | - | `tree_sitter_clojure` |
1011
| Dart | `.dart` | - | `tree_sitter_dart` |
1112
| Go | `.go` | - | `tree_sitter_go` |
1213
| Haskell | `.hs`, `.lhs` | `hs` | `tree_sitter_haskell` |
@@ -53,11 +54,18 @@
5354
- **Templates** (`template_declaration`) - Template definitions
5455
- **Namespaces** (`namespace_definition`) - Namespace definitions
5556

57+
### Clojure
58+
- **Functions** (`defn`, `defmacro`, `defn-`) - Function and macro definitions
59+
- **Variables** (`def`) - Variable definitions
60+
- **Namespaces** (`ns`) - Namespace declarations
61+
- **Classes** (`deftype`, `defrecord`) - Type and record definitions
62+
- **Interfaces** (`defprotocol`) - Protocol definitions
63+
5664
### Dart
5765
- **Functions** (`function_signature`) - Function definitions
5866
- **Methods** (`method_signature`) - Method definitions
5967
- **Classes** (`class_definition`) - Class definitions
60-
- **Enums** (`enum_declaration`) - Enum definitions
68+
- **Enums** (`enum_declaration`) - Enum declarations
6169
- **Extensions** (`extension_declaration`) - Extension definitions
6270
- **Mixins** (`mixin_declaration`) - Mixin definitions
6371

src/domain/models/color_scheme.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ pub struct ColorScheme {
147147
pub lang_haskell: SerializableColor,
148148
pub lang_dart: SerializableColor,
149149
pub lang_zig: SerializableColor,
150+
pub lang_clojure: SerializableColor,
150151
pub lang_default: SerializableColor,
151152
}
152153

@@ -325,6 +326,10 @@ impl ColorScheme {
325326
.get("lang_zig")
326327
.cloned()
327328
.unwrap_or(SerializableColor::Name("yellow".to_string())),
329+
lang_clojure: lang_colors
330+
.get("lang_clojure")
331+
.cloned()
332+
.unwrap_or(SerializableColor::Name("green".to_string())),
328333
lang_default: lang_colors
329334
.get("lang_default")
330335
.cloned()

src/domain/models/language.rs

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 Clojure;
7+
8+
impl Language for Clojure {
9+
fn name(&self) -> &'static str {
10+
"clojure"
11+
}
12+
fn extensions(&self) -> Vec<&'static str> {
13+
vec!["clj", "cljs", "cljc"]
14+
}
15+
fn aliases(&self) -> Vec<&'static str> {
16+
vec!["clojure", "clj", "cljs"]
17+
}
18+
19+
fn color(&self) -> ratatui::style::Color {
20+
Colors::lang_clojure()
21+
}
22+
23+
fn display_name(&self) -> &'static str {
24+
"Clojure"
25+
}
26+
27+
fn is_valid_comment_node(&self, node: tree_sitter::Node) -> bool {
28+
node.kind() == "comment"
29+
}
30+
}

0 commit comments

Comments
 (0)