kimchilang 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +66 -0
- package/README.md +1547 -0
- package/create-kimchi-app/README.md +44 -0
- package/create-kimchi-app/index.js +214 -0
- package/create-kimchi-app/package.json +22 -0
- package/editors/README.md +121 -0
- package/editors/sublime/KimchiLang.sublime-syntax +138 -0
- package/editors/vscode/README.md +90 -0
- package/editors/vscode/kimchilang-1.1.0.vsix +0 -0
- package/editors/vscode/language-configuration.json +37 -0
- package/editors/vscode/package.json +55 -0
- package/editors/vscode/src/extension.js +354 -0
- package/editors/vscode/syntaxes/kimchi.tmLanguage.json +215 -0
- package/examples/api/client.km +36 -0
- package/examples/async_pipe.km +58 -0
- package/examples/basic.kimchi +109 -0
- package/examples/cli_framework/README.md +92 -0
- package/examples/cli_framework/calculator.km +61 -0
- package/examples/cli_framework/deploy.km +126 -0
- package/examples/cli_framework/greeter.km +26 -0
- package/examples/config.static +27 -0
- package/examples/config.static.js +10 -0
- package/examples/env_test.km +37 -0
- package/examples/fibonacci.kimchi +17 -0
- package/examples/greeter.km +15 -0
- package/examples/hello.js +1 -0
- package/examples/hello.kimchi +3 -0
- package/examples/js_interop.km +42 -0
- package/examples/logger_example.km +34 -0
- package/examples/memo_fibonacci.km +17 -0
- package/examples/myapp/lib/http.js +14 -0
- package/examples/myapp/lib/http.km +16 -0
- package/examples/myapp/main.km +16 -0
- package/examples/myapp/main_with_mock.km +42 -0
- package/examples/myapp/services/api.js +18 -0
- package/examples/myapp/services/api.km +18 -0
- package/examples/new_features.kimchi +52 -0
- package/examples/project_example.static +20 -0
- package/examples/readme_examples.km +240 -0
- package/examples/reduce_pattern_match.km +85 -0
- package/examples/regex_match.km +46 -0
- package/examples/sample.js +45 -0
- package/examples/sample.km +39 -0
- package/examples/secrets.static +35 -0
- package/examples/secrets.static.js +30 -0
- package/examples/shell-example.mjs +144 -0
- package/examples/shell_example.km +19 -0
- package/examples/stdlib_test.km +22 -0
- package/examples/test_example.km +69 -0
- package/examples/testing/README.md +88 -0
- package/examples/testing/http_client.km +18 -0
- package/examples/testing/math.km +48 -0
- package/examples/testing/math.test.km +93 -0
- package/examples/testing/user_service.km +29 -0
- package/examples/testing/user_service.test.km +72 -0
- package/examples/use-config.mjs +141 -0
- package/examples/use_config.km +13 -0
- package/install.sh +59 -0
- package/package.json +29 -0
- package/pantry/acorn/index.km +1 -0
- package/pantry/is_number/index.km +1 -0
- package/pantry/is_odd/index.km +2 -0
- package/project.static +6 -0
- package/src/cli.js +1245 -0
- package/src/generator.js +1241 -0
- package/src/index.js +141 -0
- package/src/js2km.js +568 -0
- package/src/lexer.js +822 -0
- package/src/linter.js +810 -0
- package/src/package-manager.js +307 -0
- package/src/parser.js +1876 -0
- package/src/static-parser.js +500 -0
- package/src/typechecker.js +950 -0
- package/stdlib/array.km +0 -0
- package/stdlib/bitwise.km +38 -0
- package/stdlib/console.km +49 -0
- package/stdlib/date.km +97 -0
- package/stdlib/function.km +44 -0
- package/stdlib/http.km +197 -0
- package/stdlib/http.md +333 -0
- package/stdlib/index.km +26 -0
- package/stdlib/json.km +17 -0
- package/stdlib/logger.js +114 -0
- package/stdlib/logger.km +104 -0
- package/stdlib/math.km +120 -0
- package/stdlib/object.km +41 -0
- package/stdlib/promise.km +33 -0
- package/stdlib/string.km +93 -0
- package/stdlib/testing.md +265 -0
- package/test/test.js +599 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# create-kimchi-app
|
|
2
|
+
|
|
3
|
+
Bootstrap a new KimchiLang application with a single command.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx create-kimchi-app my-app
|
|
9
|
+
cd my-app
|
|
10
|
+
kimchi src.main
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## What's Included
|
|
14
|
+
|
|
15
|
+
The generated project includes:
|
|
16
|
+
|
|
17
|
+
- `project.static` - Project configuration
|
|
18
|
+
- `src/main.km` - Main entry point
|
|
19
|
+
- `lib/utils.km` - Example utility module
|
|
20
|
+
- `tests/utils.test.km` - Example tests
|
|
21
|
+
- `.gitignore` - Git ignore file
|
|
22
|
+
- `README.md` - Project documentation
|
|
23
|
+
|
|
24
|
+
## Project Structure
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
my-app/
|
|
28
|
+
├── project.static
|
|
29
|
+
├── README.md
|
|
30
|
+
├── .gitignore
|
|
31
|
+
├── src/
|
|
32
|
+
│ └── main.km
|
|
33
|
+
├── lib/
|
|
34
|
+
│ └── utils.km
|
|
35
|
+
└── tests/
|
|
36
|
+
└── utils.test.km
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Options
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx create-kimchi-app --help # Show help
|
|
43
|
+
npx create-kimchi-app --version # Show version
|
|
44
|
+
```
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { mkdirSync, writeFileSync, existsSync, cpSync } from 'fs';
|
|
4
|
+
import { resolve, join, dirname } from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
const TEMPLATE_DIR = join(__dirname, 'template');
|
|
11
|
+
|
|
12
|
+
const COLORS = {
|
|
13
|
+
reset: '\x1b[0m',
|
|
14
|
+
bright: '\x1b[1m',
|
|
15
|
+
green: '\x1b[32m',
|
|
16
|
+
cyan: '\x1b[36m',
|
|
17
|
+
yellow: '\x1b[33m',
|
|
18
|
+
red: '\x1b[31m',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function log(message, color = '') {
|
|
22
|
+
console.log(color + message + COLORS.reset);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function createProject(projectName) {
|
|
26
|
+
const projectPath = resolve(process.cwd(), projectName);
|
|
27
|
+
|
|
28
|
+
if (existsSync(projectPath)) {
|
|
29
|
+
log(`\nError: Directory "${projectName}" already exists.`, COLORS.red);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
log(`\n🌶️ Creating KimchiLang project: ${projectName}\n`, COLORS.bright + COLORS.cyan);
|
|
34
|
+
|
|
35
|
+
// Create project directory
|
|
36
|
+
mkdirSync(projectPath, { recursive: true });
|
|
37
|
+
|
|
38
|
+
// Create project structure
|
|
39
|
+
const dirs = ['src', 'lib', 'tests'];
|
|
40
|
+
for (const dir of dirs) {
|
|
41
|
+
mkdirSync(join(projectPath, dir), { recursive: true });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Create project.static
|
|
45
|
+
writeFileSync(join(projectPath, 'project.static'), `// KimchiLang Project Configuration
|
|
46
|
+
name "${projectName}"
|
|
47
|
+
version "1.0.0"
|
|
48
|
+
|
|
49
|
+
// External dependencies (uncomment to add)
|
|
50
|
+
// depend [
|
|
51
|
+
// "github.com/kimchilang/stdlib"
|
|
52
|
+
// ]
|
|
53
|
+
`);
|
|
54
|
+
|
|
55
|
+
// Create main entry point
|
|
56
|
+
writeFileSync(join(projectPath, 'src', 'main.km'), `// ${projectName} - Main Entry Point
|
|
57
|
+
|
|
58
|
+
// Example function
|
|
59
|
+
expose fn greet(name) {
|
|
60
|
+
return "Hello, \${name}! Welcome to KimchiLang 🌶️"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Run when executed directly
|
|
64
|
+
dec message = greet("World")
|
|
65
|
+
print message
|
|
66
|
+
`);
|
|
67
|
+
|
|
68
|
+
// Create a lib module
|
|
69
|
+
writeFileSync(join(projectPath, 'lib', 'utils.km'), `// Utility functions
|
|
70
|
+
|
|
71
|
+
expose fn add(a, b) {
|
|
72
|
+
return a + b
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
expose fn multiply(a, b) {
|
|
76
|
+
return a * b
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
expose fn range(start, end) {
|
|
80
|
+
return start..end
|
|
81
|
+
}
|
|
82
|
+
`);
|
|
83
|
+
|
|
84
|
+
// Create a test file
|
|
85
|
+
writeFileSync(join(projectPath, 'tests', 'utils.test.km'), `// Tests for lib/utils.km
|
|
86
|
+
as utils dep lib.utils
|
|
87
|
+
|
|
88
|
+
describe "Utils" {
|
|
89
|
+
test "add returns correct sum" {
|
|
90
|
+
expect(utils.add(2, 3)).toBe(5)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
test "multiply returns correct product" {
|
|
94
|
+
expect(utils.multiply(3, 4)).toBe(12)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
test "range creates array" {
|
|
98
|
+
dec nums = utils.range(1, 5)
|
|
99
|
+
expect(nums).toHaveLength(4)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
`);
|
|
103
|
+
|
|
104
|
+
// Create README
|
|
105
|
+
writeFileSync(join(projectPath, 'README.md'), `# ${projectName}
|
|
106
|
+
|
|
107
|
+
A KimchiLang project.
|
|
108
|
+
|
|
109
|
+
## Getting Started
|
|
110
|
+
|
|
111
|
+
\`\`\`bash
|
|
112
|
+
# Run the main module
|
|
113
|
+
kimchi src.main
|
|
114
|
+
|
|
115
|
+
# Run tests
|
|
116
|
+
kimchi tests.utils.test
|
|
117
|
+
|
|
118
|
+
# Install dependencies (if any)
|
|
119
|
+
kimchi install
|
|
120
|
+
\`\`\`
|
|
121
|
+
|
|
122
|
+
## Project Structure
|
|
123
|
+
|
|
124
|
+
\`\`\`
|
|
125
|
+
${projectName}/
|
|
126
|
+
├── project.static # Project configuration
|
|
127
|
+
├── src/
|
|
128
|
+
│ └── main.km # Main entry point
|
|
129
|
+
├── lib/
|
|
130
|
+
│ └── utils.km # Utility functions
|
|
131
|
+
└── tests/
|
|
132
|
+
└── utils.test.km # Unit tests
|
|
133
|
+
\`\`\`
|
|
134
|
+
|
|
135
|
+
## Learn More
|
|
136
|
+
|
|
137
|
+
- [KimchiLang Documentation](https://github.com/kimchilang/kimchilang)
|
|
138
|
+
`);
|
|
139
|
+
|
|
140
|
+
// Create .gitignore
|
|
141
|
+
writeFileSync(join(projectPath, '.gitignore'), `# Dependencies
|
|
142
|
+
.km_modules/
|
|
143
|
+
|
|
144
|
+
# Compiled output
|
|
145
|
+
*.js
|
|
146
|
+
!*.config.js
|
|
147
|
+
|
|
148
|
+
# IDE
|
|
149
|
+
.idea/
|
|
150
|
+
.vscode/
|
|
151
|
+
*.swp
|
|
152
|
+
*.swo
|
|
153
|
+
|
|
154
|
+
# OS
|
|
155
|
+
.DS_Store
|
|
156
|
+
Thumbs.db
|
|
157
|
+
`);
|
|
158
|
+
|
|
159
|
+
log(' Created project structure:', COLORS.green);
|
|
160
|
+
log(` ${projectName}/`);
|
|
161
|
+
log(' ├── project.static');
|
|
162
|
+
log(' ├── README.md');
|
|
163
|
+
log(' ├── .gitignore');
|
|
164
|
+
log(' ├── src/');
|
|
165
|
+
log(' │ └── main.km');
|
|
166
|
+
log(' ├── lib/');
|
|
167
|
+
log(' │ └── utils.km');
|
|
168
|
+
log(' └── tests/');
|
|
169
|
+
log(' └── utils.test.km');
|
|
170
|
+
|
|
171
|
+
log('\n✨ Done! To get started:\n', COLORS.bright + COLORS.green);
|
|
172
|
+
log(` cd ${projectName}`, COLORS.cyan);
|
|
173
|
+
log(' kimchi src.main', COLORS.cyan);
|
|
174
|
+
log('');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function showHelp() {
|
|
178
|
+
log('\n🌶️ create-kimchi-app\n', COLORS.bright + COLORS.cyan);
|
|
179
|
+
log('Usage:');
|
|
180
|
+
log(' npx create-kimchi-app <project-name>');
|
|
181
|
+
log(' npx create-kimchi-app my-app\n');
|
|
182
|
+
log('Options:');
|
|
183
|
+
log(' --help, -h Show this help message');
|
|
184
|
+
log(' --version Show version\n');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Main
|
|
188
|
+
const args = process.argv.slice(2);
|
|
189
|
+
|
|
190
|
+
if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
|
|
191
|
+
showHelp();
|
|
192
|
+
process.exit(0);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (args.includes('--version')) {
|
|
196
|
+
log('create-kimchi-app v1.0.0');
|
|
197
|
+
process.exit(0);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const projectName = args[0];
|
|
201
|
+
|
|
202
|
+
if (!projectName || projectName.startsWith('-')) {
|
|
203
|
+
log('\nError: Please provide a project name.', COLORS.red);
|
|
204
|
+
showHelp();
|
|
205
|
+
process.exit(1);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Validate project name
|
|
209
|
+
if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(projectName)) {
|
|
210
|
+
log('\nError: Project name must start with a letter and contain only letters, numbers, underscores, and hyphens.', COLORS.red);
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
createProject(projectName);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-kimchi-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Create a new KimchiLang application",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-kimchi-app": "./index.js"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"kimchi",
|
|
11
|
+
"kimchilang",
|
|
12
|
+
"create",
|
|
13
|
+
"bootstrap",
|
|
14
|
+
"cli"
|
|
15
|
+
],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/kimchilang/kimchilang"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# KimchiLang Editor Support
|
|
2
|
+
|
|
3
|
+
Syntax highlighting packages for various editors.
|
|
4
|
+
|
|
5
|
+
## VS Code / Windsurf
|
|
6
|
+
|
|
7
|
+
The `vscode/` folder contains a VS Code extension that provides:
|
|
8
|
+
- Syntax highlighting for `.km`, `.kimchi`, `.kc` files
|
|
9
|
+
- Bracket matching and auto-closing
|
|
10
|
+
- Comment toggling
|
|
11
|
+
|
|
12
|
+
### Installation
|
|
13
|
+
|
|
14
|
+
**Option 1: Copy to extensions folder**
|
|
15
|
+
```bash
|
|
16
|
+
cp -r editors/vscode ~/.vscode/extensions/kimchilang
|
|
17
|
+
# or for Windsurf:
|
|
18
|
+
cp -r editors/vscode ~/.windsurf/extensions/kimchilang
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Option 2: Package as VSIX**
|
|
22
|
+
```bash
|
|
23
|
+
cd editors/vscode
|
|
24
|
+
npm install -g @vscode/vsce
|
|
25
|
+
vsce package
|
|
26
|
+
# Then install the .vsix file in VS Code/Windsurf
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Sublime Text
|
|
30
|
+
|
|
31
|
+
The `sublime/` folder contains a Sublime Text syntax definition.
|
|
32
|
+
|
|
33
|
+
### Installation
|
|
34
|
+
|
|
35
|
+
Copy `KimchiLang.sublime-syntax` to your Sublime Text packages folder:
|
|
36
|
+
- **macOS**: `~/Library/Application Support/Sublime Text/Packages/User/`
|
|
37
|
+
- **Linux**: `~/.config/sublime-text/Packages/User/`
|
|
38
|
+
- **Windows**: `%APPDATA%\Sublime Text\Packages\User\`
|
|
39
|
+
|
|
40
|
+
## Vim/Neovim
|
|
41
|
+
|
|
42
|
+
Create `~/.vim/syntax/kimchi.vim` or `~/.config/nvim/syntax/kimchi.vim`:
|
|
43
|
+
|
|
44
|
+
```vim
|
|
45
|
+
" KimchiLang syntax file
|
|
46
|
+
if exists("b:current_syntax")
|
|
47
|
+
finish
|
|
48
|
+
endif
|
|
49
|
+
|
|
50
|
+
" Keywords
|
|
51
|
+
syn keyword kimchiKeyword fn dec as dep arg expose
|
|
52
|
+
syn keyword kimchiControl if else for while return try catch throw in await async
|
|
53
|
+
syn keyword kimchiBuiltin print new
|
|
54
|
+
syn keyword kimchiBoolean true false
|
|
55
|
+
syn keyword kimchiNull null undefined
|
|
56
|
+
|
|
57
|
+
" Strings
|
|
58
|
+
syn region kimchiString start=/"/ skip=/\\"/ end=/"/
|
|
59
|
+
syn region kimchiString start=/'/ skip=/\\'/ end=/'/
|
|
60
|
+
|
|
61
|
+
" Numbers
|
|
62
|
+
syn match kimchiNumber "\<\d\+\>"
|
|
63
|
+
syn match kimchiNumber "\<\d\+\.\d\+\>"
|
|
64
|
+
syn match kimchiNumber "\<0x[0-9a-fA-F]\+\>"
|
|
65
|
+
|
|
66
|
+
" Comments
|
|
67
|
+
syn match kimchiComment "//.*$"
|
|
68
|
+
syn region kimchiComment start="/\*" end="\*/"
|
|
69
|
+
|
|
70
|
+
" Operators
|
|
71
|
+
syn match kimchiOperator "=>"
|
|
72
|
+
syn match kimchiOperator "|>"
|
|
73
|
+
syn match kimchiOperator "\.\."
|
|
74
|
+
syn match kimchiOperator "\.\.\."
|
|
75
|
+
|
|
76
|
+
" Pattern matching
|
|
77
|
+
syn region kimchiPattern start="|" end="|" contains=kimchiString,kimchiNumber,kimchiBoolean
|
|
78
|
+
|
|
79
|
+
" Highlighting
|
|
80
|
+
hi def link kimchiKeyword Keyword
|
|
81
|
+
hi def link kimchiControl Conditional
|
|
82
|
+
hi def link kimchiBuiltin Function
|
|
83
|
+
hi def link kimchiBoolean Boolean
|
|
84
|
+
hi def link kimchiNull Constant
|
|
85
|
+
hi def link kimchiString String
|
|
86
|
+
hi def link kimchiNumber Number
|
|
87
|
+
hi def link kimchiComment Comment
|
|
88
|
+
hi def link kimchiOperator Operator
|
|
89
|
+
hi def link kimchiPattern Special
|
|
90
|
+
|
|
91
|
+
let b:current_syntax = "kimchi"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Add to `~/.vimrc` or `~/.config/nvim/init.vim`:
|
|
95
|
+
```vim
|
|
96
|
+
au BufRead,BufNewFile *.km,*.kimchi,*.kc set filetype=kimchi
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Emacs
|
|
100
|
+
|
|
101
|
+
Add to your Emacs config:
|
|
102
|
+
|
|
103
|
+
```elisp
|
|
104
|
+
(define-derived-mode kimchi-mode prog-mode "Kimchi"
|
|
105
|
+
"Major mode for editing KimchiLang files."
|
|
106
|
+
(setq-local comment-start "// ")
|
|
107
|
+
(setq-local comment-end "")
|
|
108
|
+
|
|
109
|
+
(setq font-lock-defaults
|
|
110
|
+
'((("\\<\\(fn\\|dec\\|as\\|dep\\|arg\\|expose\\)\\>" . font-lock-keyword-face)
|
|
111
|
+
("\\<\\(if\\|else\\|for\\|while\\|return\\|try\\|catch\\|throw\\|in\\)\\>" . font-lock-keyword-face)
|
|
112
|
+
("\\<\\(true\\|false\\|null\\|undefined\\)\\>" . font-lock-constant-face)
|
|
113
|
+
("\\<\\(print\\|new\\)\\>" . font-lock-builtin-face)
|
|
114
|
+
("\"[^\"]*\"" . font-lock-string-face)
|
|
115
|
+
("//.*$" . font-lock-comment-face)
|
|
116
|
+
("\\<[0-9]+\\>" . font-lock-constant-face)))))
|
|
117
|
+
|
|
118
|
+
(add-to-list 'auto-mode-alist '("\\.km\\'" . kimchi-mode))
|
|
119
|
+
(add-to-list 'auto-mode-alist '("\\.kimchi\\'" . kimchi-mode))
|
|
120
|
+
(add-to-list 'auto-mode-alist '("\\.kc\\'" . kimchi-mode))
|
|
121
|
+
```
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
%YAML 1.2
|
|
2
|
+
---
|
|
3
|
+
name: KimchiLang
|
|
4
|
+
file_extensions:
|
|
5
|
+
- km
|
|
6
|
+
- kimchi
|
|
7
|
+
- kc
|
|
8
|
+
- static
|
|
9
|
+
scope: source.kimchi
|
|
10
|
+
|
|
11
|
+
contexts:
|
|
12
|
+
main:
|
|
13
|
+
- include: comments
|
|
14
|
+
- include: strings
|
|
15
|
+
- include: numbers
|
|
16
|
+
- include: keywords
|
|
17
|
+
- include: storage
|
|
18
|
+
- include: constants
|
|
19
|
+
- include: operators
|
|
20
|
+
- include: pattern-matching
|
|
21
|
+
- include: functions
|
|
22
|
+
|
|
23
|
+
comments:
|
|
24
|
+
- match: //.*$
|
|
25
|
+
scope: comment.line.double-slash.kimchi
|
|
26
|
+
- match: /\*
|
|
27
|
+
scope: punctuation.definition.comment.begin.kimchi
|
|
28
|
+
push:
|
|
29
|
+
- meta_scope: comment.block.kimchi
|
|
30
|
+
- match: \*/
|
|
31
|
+
scope: punctuation.definition.comment.end.kimchi
|
|
32
|
+
pop: true
|
|
33
|
+
|
|
34
|
+
strings:
|
|
35
|
+
- match: '"'
|
|
36
|
+
scope: punctuation.definition.string.begin.kimchi
|
|
37
|
+
push:
|
|
38
|
+
- meta_scope: string.quoted.double.kimchi
|
|
39
|
+
- match: \\.
|
|
40
|
+
scope: constant.character.escape.kimchi
|
|
41
|
+
- match: '"'
|
|
42
|
+
scope: punctuation.definition.string.end.kimchi
|
|
43
|
+
pop: true
|
|
44
|
+
- match: "'"
|
|
45
|
+
scope: punctuation.definition.string.begin.kimchi
|
|
46
|
+
push:
|
|
47
|
+
- meta_scope: string.quoted.single.kimchi
|
|
48
|
+
- match: \\.
|
|
49
|
+
scope: constant.character.escape.kimchi
|
|
50
|
+
- match: "'"
|
|
51
|
+
scope: punctuation.definition.string.end.kimchi
|
|
52
|
+
pop: true
|
|
53
|
+
- match: "`"
|
|
54
|
+
scope: punctuation.definition.string.begin.kimchi
|
|
55
|
+
push:
|
|
56
|
+
- meta_scope: string.template.kimchi
|
|
57
|
+
- match: \\.
|
|
58
|
+
scope: constant.character.escape.kimchi
|
|
59
|
+
- match: \$\{
|
|
60
|
+
scope: punctuation.section.interpolation.begin.kimchi
|
|
61
|
+
push:
|
|
62
|
+
- meta_scope: meta.interpolation.kimchi
|
|
63
|
+
- match: \}
|
|
64
|
+
scope: punctuation.section.interpolation.end.kimchi
|
|
65
|
+
pop: true
|
|
66
|
+
- include: main
|
|
67
|
+
- match: "`"
|
|
68
|
+
scope: punctuation.definition.string.end.kimchi
|
|
69
|
+
pop: true
|
|
70
|
+
|
|
71
|
+
numbers:
|
|
72
|
+
- match: \b0x[0-9a-fA-F]+\b
|
|
73
|
+
scope: constant.numeric.hex.kimchi
|
|
74
|
+
- match: \b\d+\.\d+\b
|
|
75
|
+
scope: constant.numeric.float.kimchi
|
|
76
|
+
- match: \b\d+\b
|
|
77
|
+
scope: constant.numeric.integer.kimchi
|
|
78
|
+
|
|
79
|
+
keywords:
|
|
80
|
+
- match: \b(if|else|for|while|return|try|catch|throw|in|await|async|break|continue)\b
|
|
81
|
+
scope: keyword.control.kimchi
|
|
82
|
+
- match: \b(dep|arg|expose|print|new|shell|js|test|describe|expect|assert|secret|env|enum|is)\b
|
|
83
|
+
scope: keyword.other.kimchi
|
|
84
|
+
- match: \b(and|or|not)\b
|
|
85
|
+
scope: keyword.operator.logical.kimchi
|
|
86
|
+
|
|
87
|
+
storage:
|
|
88
|
+
- match: \b(fn|memo)\b
|
|
89
|
+
scope: storage.type.function.kimchi
|
|
90
|
+
- match: \b(dec|var)\b
|
|
91
|
+
scope: storage.type.kimchi
|
|
92
|
+
- match: \b(as)\b
|
|
93
|
+
scope: storage.type.kimchi
|
|
94
|
+
- match: \b(expose)\b
|
|
95
|
+
scope: storage.modifier.kimchi
|
|
96
|
+
|
|
97
|
+
constants:
|
|
98
|
+
- match: \b(true|false)\b
|
|
99
|
+
scope: constant.language.boolean.kimchi
|
|
100
|
+
- match: \b(null|undefined)\b
|
|
101
|
+
scope: constant.language.null.kimchi
|
|
102
|
+
|
|
103
|
+
operators:
|
|
104
|
+
- match: =>
|
|
105
|
+
scope: keyword.operator.arrow.kimchi
|
|
106
|
+
- match: \|>
|
|
107
|
+
scope: keyword.operator.flow.kimchi
|
|
108
|
+
- match: \.\.\.
|
|
109
|
+
scope: keyword.operator.spread.kimchi
|
|
110
|
+
- match: \.\.
|
|
111
|
+
scope: keyword.operator.range.kimchi
|
|
112
|
+
- match: (===|!==|==|!=|<=|>=|<|>)
|
|
113
|
+
scope: keyword.operator.comparison.kimchi
|
|
114
|
+
- match: (&&|\|\||!)
|
|
115
|
+
scope: keyword.operator.logical.kimchi
|
|
116
|
+
- match: (\+|-|\*|/|%)
|
|
117
|
+
scope: keyword.operator.arithmetic.kimchi
|
|
118
|
+
- match: =
|
|
119
|
+
scope: keyword.operator.assignment.kimchi
|
|
120
|
+
|
|
121
|
+
pattern-matching:
|
|
122
|
+
- match: \|(?!>)
|
|
123
|
+
scope: punctuation.definition.pattern.begin.kimchi
|
|
124
|
+
push:
|
|
125
|
+
- meta_scope: meta.pattern-match.kimchi
|
|
126
|
+
- match: \|\s*=>
|
|
127
|
+
scope: punctuation.definition.pattern.end.kimchi
|
|
128
|
+
pop: true
|
|
129
|
+
- include: main
|
|
130
|
+
|
|
131
|
+
functions:
|
|
132
|
+
- match: \b(fn)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\(
|
|
133
|
+
captures:
|
|
134
|
+
1: storage.type.function.kimchi
|
|
135
|
+
2: entity.name.function.kimchi
|
|
136
|
+
- match: \b([a-zA-Z_][a-zA-Z0-9_]*)\s*\(
|
|
137
|
+
captures:
|
|
138
|
+
1: variable.function.kimchi
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# KimchiLang VS Code Extension
|
|
2
|
+
|
|
3
|
+
Syntax highlighting, error checking, and language support for KimchiLang.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Syntax highlighting** for `.km`, `.kimchi`, `.kc`, and `.static` files
|
|
8
|
+
- **Real-time error checking** - See compile-time errors as you type
|
|
9
|
+
- **Diagnostics on save** - Errors are highlighted with red squiggles
|
|
10
|
+
- Bracket matching and auto-closing
|
|
11
|
+
- Comment toggling (line comments with `//`)
|
|
12
|
+
- Code folding
|
|
13
|
+
|
|
14
|
+
## Error Checking
|
|
15
|
+
|
|
16
|
+
The extension provides real-time error checking for KimchiLang files:
|
|
17
|
+
|
|
18
|
+
- **Parse errors** - Syntax issues like unclosed braces, brackets, or strings
|
|
19
|
+
- **Type errors** - Type mismatches caught by the type checker
|
|
20
|
+
- **Lint errors** - Code quality issues
|
|
21
|
+
|
|
22
|
+
Errors appear as red squiggly underlines in the editor, and are listed in the Problems panel (`Ctrl+Shift+M` / `Cmd+Shift+M`).
|
|
23
|
+
|
|
24
|
+
### Configuration
|
|
25
|
+
|
|
26
|
+
You can configure error checking in VS Code settings:
|
|
27
|
+
|
|
28
|
+
- `kimchi.validateOnSave` - Validate files when saved (default: true)
|
|
29
|
+
- `kimchi.validateOnChange` - Validate files as you type (default: true)
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
### From VSIX (Recommended)
|
|
34
|
+
|
|
35
|
+
1. Package the extension:
|
|
36
|
+
```bash
|
|
37
|
+
cd editors/vscode
|
|
38
|
+
npx vsce package
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
2. Install in VS Code:
|
|
42
|
+
- Open VS Code
|
|
43
|
+
- Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac)
|
|
44
|
+
- Type "Install from VSIX"
|
|
45
|
+
- Select the generated `.vsix` file
|
|
46
|
+
|
|
47
|
+
### Manual Installation
|
|
48
|
+
|
|
49
|
+
1. Copy the `editors/vscode` folder to your VS Code extensions directory:
|
|
50
|
+
- **Windows**: `%USERPROFILE%\.vscode\extensions\kimchilang`
|
|
51
|
+
- **macOS**: `~/.vscode/extensions/kimchilang`
|
|
52
|
+
- **Linux**: `~/.vscode/extensions/kimchilang`
|
|
53
|
+
|
|
54
|
+
2. Restart VS Code
|
|
55
|
+
|
|
56
|
+
## Syntax Highlighting
|
|
57
|
+
|
|
58
|
+
The extension highlights:
|
|
59
|
+
|
|
60
|
+
- **Keywords**: `fn`, `dec`, `if`, `else`, `for`, `while`, `return`, `try`, `catch`, `throw`
|
|
61
|
+
- **Storage**: `fn`, `dec`, `as`, `expose`
|
|
62
|
+
- **Control**: `dep`, `arg`, `print`, `new`
|
|
63
|
+
- **Constants**: `true`, `false`, `null`, `undefined`
|
|
64
|
+
- **Operators**: `=>`, `|>`, `..`, `...`, comparison, arithmetic
|
|
65
|
+
- **Pattern Matching**: `|condition| => { ... }`
|
|
66
|
+
- **Strings**: Double quotes, single quotes, template literals
|
|
67
|
+
- **Numbers**: Integers, floats, hex
|
|
68
|
+
- **Comments**: Line (`//`) and block (`/* */`)
|
|
69
|
+
|
|
70
|
+
## Example
|
|
71
|
+
|
|
72
|
+
```kimchi
|
|
73
|
+
// KimchiLang example
|
|
74
|
+
dec nums = [1, 2, 3, 4, 5]
|
|
75
|
+
|
|
76
|
+
fn double(x) {
|
|
77
|
+
return x * 2
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
dec doubled = nums.map((x) => x * 2)
|
|
81
|
+
print "Sum: " + nums.sum()
|
|
82
|
+
|
|
83
|
+
|nums.length > 0| => {
|
|
84
|
+
print "Array has items"
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"comments": {
|
|
3
|
+
"lineComment": "//"
|
|
4
|
+
},
|
|
5
|
+
"brackets": [
|
|
6
|
+
["{", "}"],
|
|
7
|
+
["[", "]"],
|
|
8
|
+
["(", ")"],
|
|
9
|
+
["|", "|"]
|
|
10
|
+
],
|
|
11
|
+
"autoClosingPairs": [
|
|
12
|
+
{ "open": "{", "close": "}" },
|
|
13
|
+
{ "open": "[", "close": "]" },
|
|
14
|
+
{ "open": "(", "close": ")" },
|
|
15
|
+
{ "open": "\"", "close": "\"", "notIn": ["string"] },
|
|
16
|
+
{ "open": "'", "close": "'", "notIn": ["string"] },
|
|
17
|
+
{ "open": "|", "close": "|" }
|
|
18
|
+
],
|
|
19
|
+
"surroundingPairs": [
|
|
20
|
+
["{", "}"],
|
|
21
|
+
["[", "]"],
|
|
22
|
+
["(", ")"],
|
|
23
|
+
["\"", "\""],
|
|
24
|
+
["'", "'"],
|
|
25
|
+
["|", "|"]
|
|
26
|
+
],
|
|
27
|
+
"folding": {
|
|
28
|
+
"markers": {
|
|
29
|
+
"start": "^\\s*//\\s*#?region\\b",
|
|
30
|
+
"end": "^\\s*//\\s*#?endregion\\b"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"indentationRules": {
|
|
34
|
+
"increaseIndentPattern": "^.*\\{[^}\"']*$",
|
|
35
|
+
"decreaseIndentPattern": "^\\s*\\}"
|
|
36
|
+
}
|
|
37
|
+
}
|