Skip to content

Commit b67ef4d

Browse files
committed
feat(editor): add initial VS Code syntax highlighting for OrgScript
1 parent d190edf commit b67ef4d

File tree

6 files changed

+143
-65
lines changed

6 files changed

+143
-65
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The format is based on Keep a Changelog, and this project follows Semantic Versi
2020
- Unified CLI diagnostics across `validate`, `lint`, `check`, and `format --check`.
2121
- Added stable diagnostic code namespaces for syntax, semantic validation, lint, format, and CLI usage errors.
2222
- Added `format --check --json` and documented JSON diagnostics with real examples.
23+
- Upgraded the VS Code OrgScript extension from a scaffold to a usable first TextMate-based syntax-highlighting integration.
2324

2425
## [0.3.0] - 2026-03-29
2526

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ npm run demo:generate
183183
- Golden snapshot tests for AST, canonical model, and formatter output
184184
- Stable lint severities: `error`, `warning`, `info`
185185
- Canonical master spec: [`spec/language-spec.md`](spec/language-spec.md)
186-
- Initial VS Code syntax-highlighting scaffold: [`editors/vscode`](editors/vscode)
186+
- Initial VS Code syntax-highlighting extension: [`editors/vscode`](editors/vscode)
187187
- Generated demo artifacts for Mermaid and Markdown summaries under [`docs/demos`](docs/demos)
188188

189189
## Quick start
@@ -362,13 +362,15 @@ OrgScript currently produces two human-facing output types from the same source
362362

363363
## Editor support
364364

365-
OrgScript now ships with a first VS Code syntax-highlighting scaffold under [`editors/vscode`](editors/vscode).
365+
OrgScript now ships with a first usable VS Code syntax-highlighting extension under [`editors/vscode`](editors/vscode).
366366

367367
It currently covers:
368368

369369
- `.orgs` file association
370-
- top-level blocks and core keywords
371-
- strings, numbers, and operators
370+
- top-level blocks and block names
371+
- core statements and section keywords
372+
- strings, booleans, numbers, and operators
373+
- dotted references such as `lead.status` and `lead.created`
372374

373375
See [`editors/vscode/README.md`](editors/vscode/README.md) for local installation and usage notes.
374376

docs/roadmaps/v0.4.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Make OrgScript easier to use in daily development, CI, and editor workflows with
2222
- JSON diagnostics examples in the README and diagnostics spec
2323
- stable diagnostic code namespaces and consistent CLI finding output
2424
- canonical language spec and governance notes
25-
- initial VS Code syntax-highlighting scaffold
25+
- initial VS Code syntax-highlighting extension
2626
- Markdown summary exporter
2727
- Mermaid demo package with generated Markdown and `.mmd` artifacts
2828

editors/vscode/README.md

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,51 @@
1-
# OrgScript VS Code scaffold
1+
# OrgScript VS Code
22

3-
This folder contains a minimal VS Code language contribution for `.orgs` files.
3+
This folder contains a locally testable VS Code extension for `.orgs` files.
44

55
## What is included
66

7-
- `package.json` registers the `OrgScript` language and the `.orgs` extension
8-
- `syntaxes/orgscript.tmLanguage.json` provides TextMate syntax highlighting
9-
- `language-configuration.json` adds lightweight editor behavior for quotes and brackets
7+
- `package.json` registers the `OrgScript` language with language id `orgscript`
8+
- `syntaxes/orgscript.tmLanguage.json` provides TextMate-based syntax highlighting
9+
- `language-configuration.json` adds lightweight editor behavior for double-quoted strings
1010

1111
## What is highlighted
1212

1313
- top-level blocks such as `process`, `stateflow`, `rule`, `role`, `policy`, `metric`, and `event`
14-
- core keywords such as `when`, `if`, `then`, `else`, `assign`, `transition`, `notify`, `create`, `update`, `require`, and `stop`
15-
- strings, numbers, and operators
16-
17-
OrgScript does not define a comment syntax in the language spec yet, so this scaffold intentionally does not add comment highlighting.
18-
19-
## Use locally
20-
21-
1. Open `editors/vscode/` in VS Code.
22-
2. Open a `.orgs` file from the repo, or create a new one in that folder.
23-
3. If needed, select `OrgScript` from the language mode picker in the bottom-right corner.
24-
25-
## Notes
26-
27-
- This is a syntax-highlighting scaffold only.
28-
- It does not add CLI commands, formatting, linting, or diagnostics.
14+
- block names such as `LeadQualification` or `OrderLifecycle`
15+
- section keywords such as `states`, `transitions`, `applies to`, `can`, `cannot`, `formula`, `owner`, and `target`
16+
- core statements such as `when`, `if`, `else`, `then`, `assign`, `transition`, `notify`, `create`, `update`, `require`, and `stop`
17+
- operator forms such as `=`, `!=`, `<`, `<=`, `>`, `>=`, and `->`
18+
- dotted references such as `lead.status` and `lead.created`
19+
- strings, booleans, and numeric literals
20+
21+
OrgScript does not define an official comment syntax in the language spec yet, so this extension intentionally does not add comment highlighting.
22+
23+
## Local testing in VS Code
24+
25+
1. Open the repository in VS Code.
26+
2. Open the `editors/vscode/` folder as the extension project if you want to inspect the extension files directly.
27+
3. Press `F5` in VS Code while `editors/vscode/` is the active extension workspace.
28+
4. In the Extension Development Host, open one of these files:
29+
- `examples/craft-business-lead-to-order.orgs`
30+
- `examples/order-approval.orgs`
31+
- `examples/service-escalation.orgs`
32+
5. Confirm that the language mode is `OrgScript` and that blocks, statements, strings, operators, and dotted references are highlighted.
33+
34+
## Good demo files
35+
36+
- `examples/craft-business-lead-to-order.orgs`
37+
Good for `process`, `if`, strings, dotted references, operators, and `stateflow`.
38+
- `examples/order-approval.orgs`
39+
Good for `stateflow`, `rule`, `applies to`, and transitions.
40+
- `examples/service-escalation.orgs`
41+
Good for `policy`, `event`, `metric`, and role-oriented language.
42+
43+
## Current scope
44+
45+
- TextMate grammar only
46+
- no semantic tokens
47+
- no IntelliSense
48+
- no snippets
49+
- no hover provider
50+
- no diagnostics integration
51+
- no editor-driven formatting
Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,18 @@
11
{
2-
"brackets": [
3-
["{", "}"],
4-
["[", "]"],
5-
["(", ")"]
6-
],
72
"autoClosingPairs": [
83
{
94
"open": "\"",
105
"close": "\"",
11-
"notIn": ["string"]
12-
},
13-
{
14-
"open": "(",
15-
"close": ")",
16-
"notIn": ["string", "comment"]
17-
},
18-
{
19-
"open": "[",
20-
"close": "]",
21-
"notIn": ["string", "comment"]
22-
},
23-
{
24-
"open": "{",
25-
"close": "}",
26-
"notIn": ["string", "comment"]
6+
"notIn": [
7+
"string"
8+
]
279
}
2810
],
2911
"surroundingPairs": [
30-
["\"", "\""],
31-
["(", ")"],
32-
["[", "]"],
33-
["{", "}"]
12+
[
13+
"\"",
14+
"\""
15+
]
3416
],
3517
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\s\\[\\]{}()<>=\"'`~!@#$%^&*+,.;:/?|\\\\]+)"
3618
}

editors/vscode/syntaxes/orgscript.tmLanguage.json

Lines changed: 85 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,97 @@
44
"scopeName": "source.orgscript",
55
"patterns": [
66
{
7-
"include": "#top-level-block"
7+
"include": "#strings"
88
},
99
{
10-
"include": "#keywords"
10+
"include": "#top-level-blocks"
1111
},
1212
{
13-
"include": "#strings"
13+
"include": "#section-keywords"
14+
},
15+
{
16+
"include": "#control-keywords"
17+
},
18+
{
19+
"include": "#statement-keywords"
20+
},
21+
{
22+
"include": "#booleans"
1423
},
1524
{
1625
"include": "#numbers"
1726
},
1827
{
1928
"include": "#operators"
29+
},
30+
{
31+
"include": "#references"
2032
}
2133
],
2234
"repository": {
23-
"top-level-block": {
35+
"top-level-blocks": {
2436
"patterns": [
2537
{
26-
"match": "^(\\s*)(process|stateflow|rule|role|policy|metric|event)\\b(?:\\s+([A-Za-z_][\\w.-]*))?",
27-
"name": "meta.block.orgscript",
38+
"match": "^(\\s*)(process|stateflow|rule|role|policy|metric|event)(\\s+)([A-Za-z_][A-Za-z0-9_.-]*)\\b",
2839
"captures": {
2940
"2": {
30-
"name": "keyword.control.orgscript"
41+
"name": "storage.type.orgscript"
3142
},
32-
"3": {
43+
"4": {
3344
"name": "entity.name.type.orgscript"
3445
}
3546
}
3647
}
3748
]
3849
},
39-
"keywords": {
50+
"section-keywords": {
51+
"patterns": [
52+
{
53+
"match": "^(\\s*)(states|transitions|can|cannot|formula|owner|target)\\b",
54+
"captures": {
55+
"2": {
56+
"name": "keyword.declaration.orgscript"
57+
}
58+
}
59+
},
60+
{
61+
"match": "^(\\s*)(applies)(\\s+)(to)\\b",
62+
"captures": {
63+
"2": {
64+
"name": "keyword.declaration.orgscript"
65+
},
66+
"4": {
67+
"name": "keyword.declaration.orgscript"
68+
}
69+
}
70+
}
71+
]
72+
},
73+
"control-keywords": {
4074
"patterns": [
4175
{
42-
"match": "\\b(?:when|if|then|else|assign|transition|notify|create|update|require|stop|applies to|states|transitions|can|cannot|formula|owner|target|with|to|and|or)\\b",
43-
"name": "keyword.control.orgscript"
76+
"match": "^(\\s*)(if|when|then|else)\\b",
77+
"captures": {
78+
"2": {
79+
"name": "keyword.control.orgscript"
80+
}
81+
}
82+
},
83+
{
84+
"match": "\\b(with|to|and|or)\\b",
85+
"name": "keyword.operator.word.orgscript"
86+
}
87+
]
88+
},
89+
"statement-keywords": {
90+
"patterns": [
91+
{
92+
"match": "^(\\s*)(assign|transition|notify|create|update|require|stop)\\b",
93+
"captures": {
94+
"2": {
95+
"name": "keyword.control.orgscript"
96+
}
97+
}
4498
}
4599
]
46100
},
@@ -59,19 +113,35 @@
59113
}
60114
]
61115
},
116+
"booleans": {
117+
"patterns": [
118+
{
119+
"match": "\\b(?:true|false)\\b",
120+
"name": "constant.language.boolean.orgscript"
121+
}
122+
]
123+
},
62124
"numbers": {
63125
"patterns": [
64126
{
65-
"name": "constant.numeric.orgscript",
66-
"match": "\\b\\d+(?:\\.\\d+)?(?:[smhd])?\\b"
127+
"match": "\\b-?\\d+(?:\\.\\d+)?\\b",
128+
"name": "constant.numeric.orgscript"
67129
}
68130
]
69131
},
70132
"operators": {
71133
"patterns": [
72134
{
73-
"name": "keyword.operator.orgscript",
74-
"match": "(?:!=|<=|>=|->|=|<|>)"
135+
"match": "(?:!=|<=|>=|->|=|<|>)",
136+
"name": "keyword.operator.orgscript"
137+
}
138+
]
139+
},
140+
"references": {
141+
"patterns": [
142+
{
143+
"match": "\\b[A-Za-z_][A-Za-z0-9_-]*(?:\\.[A-Za-z_][A-Za-z0-9_-]*)+\\b",
144+
"name": "variable.other.member.orgscript"
75145
}
76146
]
77147
}

0 commit comments

Comments
 (0)