Skip to content

Commit 409c301

Browse files
committed
feat: add ZynML VS Code syntax highlighting extension
Adds a local VS Code extension for ZynML syntax highlighting: - TextMate grammar for .zynml and .zyn files - Keywords: def, fn, struct, enum, trait, impl, effect, handler - Control flow: if, else, elif, match, case, for, while, async, await - Type highlighting: primitives, built-ins, generics - Operators: |>, =>, ->, ??, ?, :: - Annotations: @effect, @device, @jit - F-string interpolation support - Number literals with suffixes (duration, etc.) - Language configuration for brackets, comments, indentation Installed via symlink to ~/.vscode/extensions/
1 parent dbdfc13 commit 409c301

7 files changed

Lines changed: 518 additions & 1 deletion

File tree

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"zyntax.zynml-syntax"
4+
]
5+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Changelog
2+
3+
## [0.1.0] - 2026-01-17
4+
5+
### Added
6+
7+
- Initial release of ZynML syntax highlighting
8+
- Support for `.zynml` and `.zyn` file extensions
9+
- Syntax highlighting for:
10+
- Keywords: `def`, `fn`, `struct`, `enum`, `trait`, `impl`, `type`, `let`, `mut`
11+
- Control flow: `if`, `else`, `elif`, `match`, `case`, `for`, `while`, `return`
12+
- Async: `async`, `await`
13+
- Effects: `effect`, `handler`, `where`
14+
- Primitive types: `i64`, `f64`, `bool`, `str`, `String`
15+
- Built-in types: `Option`, `Result`, `List`, `HashMap`, `Tensor`, `Iterator`
16+
- Operators: `|>`, `=>`, `->`, `??`, `?`, `::`
17+
- Annotations: `@effect`, `@device`, `@jit`
18+
- String literals and f-strings with interpolation
19+
- Numbers with suffixes (duration literals, etc.)
20+
- Comments (line and block)
21+
- Language configuration for:
22+
- Bracket matching
23+
- Auto-closing pairs
24+
- Comment toggling
25+
- Indentation rules
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# ZynML Language Support
2+
3+
Syntax highlighting for ZynML - the Machine Learning DSL for Zyntax.
4+
5+
## Features
6+
7+
- Syntax highlighting for `.zynml` and `.zyn` files
8+
- Bracket matching and auto-closing
9+
- Comment toggling (`//` and `/* */`)
10+
- Code folding
11+
12+
## Highlighted Constructs
13+
14+
### Keywords
15+
- Control flow: `if`, `else`, `elif`, `match`, `case`, `for`, `while`, `return`
16+
- Declarations: `def`, `fn`, `struct`, `enum`, `trait`, `impl`, `type`, `let`, `mut`
17+
- Async: `async`, `await`
18+
- Effects: `effect`, `handler`, `where`
19+
20+
### Types
21+
- Primitives: `i64`, `f64`, `bool`, `str`, `String`
22+
- Built-ins: `Option`, `Result`, `List`, `HashMap`, `Tensor`, `Iterator`
23+
- Type variables (capitalized identifiers)
24+
25+
### Literals
26+
- Numbers with optional suffixes: `1000ms`, `5s`, `3.14`
27+
- Strings and f-strings: `"hello"`, `f"Hello {name}"`
28+
- Booleans: `true`, `false`
29+
- Option/Result: `Some`, `None`, `Ok`, `Err`
30+
31+
### Operators
32+
- Pipe: `|>`
33+
- Arrows: `=>`, `->`, `:`
34+
- Null coalesce: `??`
35+
- Optional: `?`
36+
- Path: `::`
37+
38+
### Annotations
39+
- `@effect(IO)`
40+
- `@device(GPU(0))`
41+
- `@jit`
42+
43+
## Installation
44+
45+
### Local Development
46+
47+
1. Copy or symlink this folder to your VS Code extensions directory:
48+
- macOS/Linux: `~/.vscode/extensions/`
49+
- Windows: `%USERPROFILE%\.vscode\extensions\`
50+
51+
2. Reload VS Code
52+
53+
### From Workspace
54+
55+
Add to your `.vscode/settings.json`:
56+
57+
```json
58+
{
59+
"files.associations": {
60+
"*.zynml": "zynml",
61+
"*.zyn": "zynml"
62+
}
63+
}
64+
```
65+
66+
## Example
67+
68+
```zynml
69+
// Define a struct with generics
70+
struct Point<T> {
71+
x: T,
72+
y: T
73+
}
74+
75+
// Implement Display trait
76+
impl<T> Display for Point<T>
77+
where T: Display
78+
{
79+
def to_string(self): String {
80+
f"({self.x}, {self.y})"
81+
}
82+
}
83+
84+
// Function with pattern matching
85+
def process(data: List<i64>): ?i64 {
86+
match data.first() {
87+
case Some(v) { Some(v * 2) }
88+
case None() { None }
89+
}
90+
}
91+
92+
// Async function with effect
93+
@effect(IO)
94+
async def fetch_and_process(url: String): Tensor {
95+
data = await http.get(url)
96+
data |> parse() |> normalize() |> transform()
97+
}
98+
```
99+
100+
## License
101+
102+
Apache-2.0
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"comments": {
3+
"lineComment": "//",
4+
"blockComment": ["/*", "*/"]
5+
},
6+
"brackets": [
7+
["{", "}"],
8+
["[", "]"],
9+
["(", ")"],
10+
["<", ">"]
11+
],
12+
"autoClosingPairs": [
13+
{ "open": "{", "close": "}" },
14+
{ "open": "[", "close": "]" },
15+
{ "open": "(", "close": ")" },
16+
{ "open": "<", "close": ">", "notIn": ["string"] },
17+
{ "open": "\"", "close": "\"", "notIn": ["string"] },
18+
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }
19+
],
20+
"surroundingPairs": [
21+
{ "open": "{", "close": "}" },
22+
{ "open": "[", "close": "]" },
23+
{ "open": "(", "close": ")" },
24+
{ "open": "<", "close": ">" },
25+
{ "open": "\"", "close": "\"" },
26+
{ "open": "'", "close": "'" }
27+
],
28+
"folding": {
29+
"markers": {
30+
"start": "^\\s*//\\s*region\\b",
31+
"end": "^\\s*//\\s*endregion\\b"
32+
}
33+
},
34+
"indentationRules": {
35+
"increaseIndentPattern": "^.*\\{[^}\"']*$|^.*\\([^)\"']*$|^.*\\[[^\\]\"']*$",
36+
"decreaseIndentPattern": "^\\s*[}\\]\\)]"
37+
},
38+
"wordPattern": "[a-zA-Z_][a-zA-Z0-9_]*"
39+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "zynml-syntax",
3+
"displayName": "ZynML Language Support",
4+
"description": "Syntax highlighting for ZynML - Machine Learning DSL for Zyntax",
5+
"version": "0.1.0",
6+
"publisher": "zyntax",
7+
"engines": {
8+
"vscode": "^1.75.0"
9+
},
10+
"categories": [
11+
"Programming Languages"
12+
],
13+
"contributes": {
14+
"languages": [
15+
{
16+
"id": "zynml",
17+
"aliases": ["ZynML", "zynml"],
18+
"extensions": [".zynml", ".zyn"],
19+
"configuration": "./language-configuration.json"
20+
}
21+
],
22+
"grammars": [
23+
{
24+
"language": "zynml",
25+
"scopeName": "source.zynml",
26+
"path": "./syntaxes/zynml.tmLanguage.json"
27+
}
28+
]
29+
}
30+
}

0 commit comments

Comments
 (0)