diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8e0cf80 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,24 @@ +# Changelog + +## [0.1.0] - 2025-12-24 + +### Added +- Syntax highlighting for `.toon` files +- File recognition with `.toon` extension +- Language configuration with proper indentation and brackets +- TextMate grammar for TOON syntax +- Basic example file + +### Grammar (spec-compliant) +- Array header syntax: `key[N]: v1,v2` and `key[N]{f1,f2}:` tabular headers +- Dotted key support: `user.name: value` +- List item markers: `- value` +- Strings (quoted), numbers, booleans, null values +- No comment syntax (TOON has none per spec) + +## [0.0.1] - 2025-12-24 + +### Added +- Initial project setup with TypeScript and build pipeline +- Basic extension scaffolding +- Development tooling (ESLint, tsdown, pnpm) \ No newline at end of file diff --git a/README.md b/README.md index 1a3c884..e7b3d4d 100644 --- a/README.md +++ b/README.md @@ -1,52 +1,54 @@ -# TOON Format for Visual Studio Code +# TOON for VS Code -> **⚠️ Development Status:** This extension is in early development. Bare minimum setup for team collaboration. - -Visual Studio Code extension for TOON format support. TOON is a compact, human-readable serialization format for LLM contexts with 30-60% token reduction vs JSON. +VS Code extension for TOON (Token-Oriented Object Notation) format. ## Features -Currently in development. Planned features: +- **Syntax highlighting** for `.toon` files +- **File recognition** with `.toon` extension +- **Language support** with proper indentation and brackets -- Syntax highlighting for `.toon` files -- Format validation and error detection -- Code formatting and auto-completion -- Integration with TOON specification +## Example -## Installation +```toon +name: John Doe +age: 30 +active: true -This extension is not yet published to the Visual Studio Marketplace. To install locally: +address: + street: 123 Main St + city: New York -```bash -git clone https://github.com/toon-format/vscode.git -cd toon-vscode -pnpm install -pnpm build +hobbies[3]: reading,coding,hiking + +projects[2]{id,name,status}: + 1,Alpha,active + 2,Beta,completed ``` +## Status + +**v0.1.0** - Basic syntax highlighting and file recognition ✅ + +## Roadmap + +- **v0.0.x** - Initial project setup ✅ +- **v0.1.x** - Basic syntax highlighting ✅ +- **v0.2.x** - Format validation (next) +- **v0.3.x** - Code formatting and auto-completion (planned) +- **v1.0.0** - First stable release (planned) + ## Development ```bash -# Setup -git clone https://github.com/toon-format/vscode.git -cd toon-vscode pnpm install - -# Build pnpm build +``` -# Development mode (watch) -pnpm dev - -# Run linting -pnpm lint - -# Type check -pnpm test:types +## Links -# Package extension -pnpm package -``` +- [TOON Specification](https://github.com/toon-format/spec) +- [Report Issues](https://github.com/toon-format/vscode/issues) ## Project Status & Roadmap diff --git a/docs/README.md b/docs/README.md index d3f93ab..bef0125 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,11 +1,21 @@ -# TOON VSCode Extension Documentation +# TOON Extension Docs -This directory will contain comprehensive documentation for the TOON VSCode extension. +Basic documentation for the TOON VS Code extension. -## Coming Soon +## Quick Reference -- Installation guide -- Feature documentation -- Configuration options -- Development guide -- API reference +- **File extension**: `.toon` +- **Format**: Indentation-based like YAML, tabular arrays like CSV +- **Arrays**: `key[N]: v1,v2,v3` or tabular `key[N]{f1,f2}:` +- **Dotted keys**: `user.name: value` + +## Example + +```toon +name: Example +user.role: admin +items[3]: a,b,c +rows[2]{id,name}: + 1,Alice + 2,Bob +``` diff --git a/examples/basic.toon b/examples/basic.toon new file mode 100644 index 0000000..32f036e --- /dev/null +++ b/examples/basic.toon @@ -0,0 +1,15 @@ +name: John Doe +age: 30 +active: true + +address: + street: 123 Main St + city: New York + +hobbies[3]: reading,coding,hiking + +projects[2]{id,name,status}: + 1,Alpha,active + 2,Beta,completed + +user.role: admin diff --git a/language-configuration.json b/language-configuration.json new file mode 100644 index 0000000..cdd4b28 --- /dev/null +++ b/language-configuration.json @@ -0,0 +1,20 @@ +{ + "brackets": [ + ["[", "]"], + ["{", "}"] + ], + "autoClosingPairs": [ + { "open": "[", "close": "]" }, + { "open": "{", "close": "}" }, + { "open": "\"", "close": "\"" } + ], + "surroundingPairs": [ + ["[", "]"], + ["{", "}"], + ["\"", "\""] + ], + "indentationRules": { + "increaseIndentPattern": "^\\s*(?:[A-Za-z_][A-Za-z0-9_.]*|\"[^\"]*\")(?:\\[\\d+[|\\t]?\\](?:\\{[^}]*\\})?)?:\\s*$", + "decreaseIndentPattern": "^\\s*$" + } +} diff --git a/package.json b/package.json index 1fc2c75..2cc5e6f 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "name": "toon", "displayName": "Token-Oriented Object Notation (TOON) Support", "type": "module", - "version": "0.0.1", + "version": "0.1.0", "packageManager": "pnpm@10.23.0", "description": "Visual Studio Code extension for TOON format support", "license": "MIT", @@ -18,7 +18,10 @@ "keywords": [ "toon", "format", - "serialization" + "serialization", + "llm", + "token-efficient", + "json-alternative" ], "categories": [ "Programming Languages", @@ -30,10 +33,25 @@ "node": ">=24.0.0" }, "contributes": { + "languages": [ + { + "id": "toon", + "aliases": ["TOON", "toon"], + "extensions": [".toon"], + "configuration": "./language-configuration.json" + } + ], + "grammars": [ + { + "language": "toon", + "scopeName": "source.toon", + "path": "./syntaxes/toon.tmLanguage.json" + } + ], "commands": [ { - "command": "toon.helloWorld", - "title": "TOON: Hello World" + "command": "toon.hello", + "title": "TOON: Hello" } ] }, diff --git a/src/extension.ts b/src/extension.ts index 7c976c7..b85e05c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,12 +1,12 @@ import * as vscode from 'vscode' export function activate(context: vscode.ExtensionContext): void { - // Register the hello world command - const disposable = vscode.commands.registerCommand('toon.helloWorld', () => { - vscode.window.showInformationMessage('Hello World from TOON!') + // Basic hello command for initial setup + const helloCommand = vscode.commands.registerCommand('toon.hello', () => { + vscode.window.showInformationMessage('TOON extension activated! Ready for development.') }) - context.subscriptions.push(disposable) + context.subscriptions.push(helloCommand) } export function deactivate(): void { diff --git a/syntaxes/toon.tmLanguage.json b/syntaxes/toon.tmLanguage.json new file mode 100644 index 0000000..4f76ed0 --- /dev/null +++ b/syntaxes/toon.tmLanguage.json @@ -0,0 +1,82 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "TOON", + "scopeName": "source.toon", + "patterns": [ + { "include": "#tabular-header" }, + { "include": "#array-header" }, + { "include": "#list-item" }, + { "include": "#key-value" } + ], + "repository": { + "tabular-header": { + "comment": "§6: key[N]{f1,f2}: or key[N|]{f1|f2}: or key[N\t]{f1\tf2}:", + "match": "^(\\s*)([A-Za-z_][A-Za-z0-9_.]*|\"[^\"]*\")(\\[\\d+[|\\t]?\\])(\\{[^}]*\\})(:)(.*)", + "captures": { + "2": { "name": "entity.name.tag.toon" }, + "3": { "name": "constant.numeric.toon" }, + "4": { "name": "entity.other.attribute-name.toon" }, + "5": { "name": "punctuation.separator.key-value.toon" }, + "6": { "patterns": [{ "include": "#values" }] } + } + }, + "array-header": { + "comment": "§6: key[N]: or key[N|]: or key[N\t]: — also root [N]:", + "match": "^(\\s*)([A-Za-z_][A-Za-z0-9_.]*|\"[^\"]*\")?(\\[\\d+[|\\t]?\\])(:)(.*)", + "captures": { + "2": { "name": "entity.name.tag.toon" }, + "3": { "name": "constant.numeric.toon" }, + "4": { "name": "punctuation.separator.key-value.toon" }, + "5": { "patterns": [{ "include": "#values" }] } + } + }, + "list-item": { + "comment": "§9.4, §10: list item starting with '- '", + "match": "^(\\s*)(-)( )(.*)", + "captures": { + "2": { "name": "punctuation.definition.list.begin.toon" }, + "4": { "patterns": [{ "include": "#tabular-header" }, { "include": "#array-header" }, { "include": "#key-value" }, { "include": "#values" }] } + } + }, + "key-value": { + "comment": "§7.3, §8: simple or dotted key followed by colon", + "match": "^(\\s*)([A-Za-z_][A-Za-z0-9_.]*|\"[^\"]*\")(:)(.*)", + "captures": { + "2": { "name": "entity.name.tag.toon" }, + "3": { "name": "punctuation.separator.key-value.toon" }, + "4": { "patterns": [{ "include": "#values" }] } + } + }, + "values": { + "patterns": [ + { "include": "#string-quoted" }, + { "include": "#number" }, + { "include": "#boolean" }, + { "include": "#null" } + ] + }, + "string-quoted": { + "name": "string.quoted.double.toon", + "begin": "\"", + "end": "\"", + "patterns": [ + { "name": "constant.character.escape.toon", "match": "\\\\[\\\\\"nrt]" }, + { "name": "invalid.illegal.escape.toon", "match": "\\\\." } + ] + }, + "number": { + "name": "constant.numeric.toon", + "match": "(?