about summary refs log tree commit diff stats
path: root/js/baba-yaga/dev/README.md
blob: 4d17110cf172f0ab552ac717b515ce2486b38906 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Baba Yaga Syntax Highlighting

This directory contains syntax highlighting implementations for the Baba Yaga programming language across various editors and IDEs.

## Supported Editors

### [VS Code](./vscode/)
- Complete extension with package.json, language configuration, and TextMate grammar
- **Installation**: Copy to VS Code extensions directory or build with `vsce`
- **Features**: Syntax highlighting, auto-closing brackets, indentation, code folding

### [Sublime Text](./sublime/)
- YAML-based syntax definition
- **Installation**: Copy to Sublime Text packages directory
- **Features**: Syntax highlighting, automatic file detection

### [TextMate](./textmate/)
- Complete TextMate bundle with Info.plist and grammar
- **Installation**: Double-click bundle or copy to TextMate bundles directory
- **Features**: Syntax highlighting, code folding, auto-indentation

### [Vim/NeoVim](./vim/)
- Vim syntax file and filetype detection
- **Installation**: Copy to Vim runtime directory or use plugin manager
- **Features**: Syntax highlighting, automatic file detection, custom highlighting

### [Emacs](./emacs/)
- Complete major mode with syntax highlighting and indentation
- **Installation**: Copy to Emacs load path or use package manager
- **Features**: Syntax highlighting, indentation, comment handling, key bindings

### [Helix](./helix/)
- Tree-sitter grammar and language configuration
- **Installation**: Copy to Helix languages directory
- **Features**: Syntax highlighting, Tree-sitter parsing, language server support

### [Micro](./micro/)
- YAML-based syntax highlighting rules
- **Installation**: Copy to Micro syntax directory
- **Features**: Syntax highlighting, automatic file detection

## Common Features

All implementations provide syntax highlighting for:

- **Keywords**: `when`, `then`, `is`, `Ok`, `Err`, `true`, `false`, `PI`, `INFINITY`, `and`, `or`, `xor`
- **Types**: `Bool`, `Int`, `Float`, `String`, `List`, `Table`, `Result`, `Number`
- **Operators**: `->`, `=>`, `+`, `-`, `*`, `/`, `%`, `=`, `!=`, `>`, `<`, `>=`, `<=`, `..`
- **Built-in Functions**: `map`, `filter`, `reduce`, `append`, `set`, `merge`, `shape`
- **IO Functions**: `io.out`, `io.in`
- **String Functions**: `str.concat`, `str.split`, `str.join`, `str.length`, `str.substring`, `str.replace`, `str.trim`, `str.upper`, `str.lower`
- **Math Functions**: `math.abs`, `math.sign`, `math.floor`, `math.ceil`, `math.round`, `math.trunc`, `math.min`, `math.max`, `math.clamp`, `math.pow`, `math.sqrt`, `math.exp`, `math.log`, `math.sin`, `math.cos`, `math.tan`, `math.asin`, `math.acos`, `math.atan`, `math.atan2`, `math.deg`, `math.rad`, `math.random`, `math.randomInt`
- **Comments**: `//` and `/* */`
- **Strings**: Double-quoted strings
- **Numbers**: Integers and floats
- **Variables**: Identifiers
- **Function Definitions**: `name : value;` pattern
- **When Expressions**: Pattern matching with `when`, `then`, `is`
- **Lists**: `[1, 2, 3]` syntax
- **Tables**: `{key: value}` syntax
- **Result Types**: `Ok value` and `Err message`

## Quick Installation

### VS Code
```bash
cd dev/vscode
npm install -g vsce
vsce package
# Install the generated .vsix file in VS Code
```

### Sublime Text
```bash
cp dev/sublime/Baba\ Yaga.sublime-syntax ~/.config/sublime-text/Packages/User/
```

### TextMate
```bash
cp -r dev/textmate/Baba\ Yaga.tmbundle ~/Library/Application\ Support/TextMate/Bundles/
```

### Vim/NeoVim
```bash
cp dev/vim/syntax/baba.vim ~/.vim/syntax/
cp dev/vim/ftdetect/baba.vim ~/.vim/ftdetect/
```

### Emacs
```bash
cp dev/emacs/baba-yaga-mode.el ~/.emacs.d/
# Add (require 'baba-yaga-mode) to your init file
```

### Helix
```bash
mkdir -p ~/.config/helix/languages
cp dev/helix/languages.toml ~/.config/helix/languages/
```

### Micro
```bash
mkdir -p ~/.config/micro/syntax
cp dev/micro/syntax/baba-yaga.yaml ~/.config/micro/syntax/
```

## Development

### Adding New Keywords
When adding new keywords to the Baba Yaga language, update all syntax files:

1. **VS Code**: Update `syntaxes/baba-yaga.tmLanguage.json`
2. **Sublime**: Update `Baba Yaga.sublime-syntax`
3. **TextMate**: Update `Syntaxes/Baba Yaga.tmLanguage`
4. **Vim**: Update `syntax/baba.vim`
5. **Emacs**: Update `baba-yaga-mode.el`
6. **Helix**: Update `grammar.js`
7. **Micro**: Update `syntax/baba-yaga.yaml`

### Testing
Test each implementation with a sample `.baba` file:

```baba
// Test file for syntax highlighting
myVar : 42;
myString : "Hello, Baba Yaga!";
myFunction : x -> x + 1;
myResult : when x is
  1 then "One"
  _ then "Other";

// Test built-in functions
io.out "Testing";
doubled : map (x -> x * 2) [1 2 3];
length : str.length "hello";
abs : math.abs -5;
```

### Color Schemes
All implementations use standard editor color schemes. Custom themes can be created by targeting the appropriate scopes:

- `source.baba-yaga` - Main scope
- `keyword.control.baba-yaga` - Keywords
- `storage.type.baba-yaga` - Types
- `keyword.operator.baba-yaga` - Operators
- `string.quoted.double.baba-yaga` - Strings
- `comment.line.double-slash.baba-yaga` - Comments

## Contributing

When contributing syntax highlighting improvements:

1. Test with the sample code above
2. Ensure consistency across all editors
3. Update this README if adding new features
4. Follow the existing code style for each editor
5. Verify against the actual Baba Yaga language specification

## License

All syntax highlighting files are provided under the same license as the main Baba Yaga project.