|
| 1 | +# Contributing Extensions |
| 2 | + |
| 3 | +This repository contains extensions for the [Athas](https://athas.dev) editor. Extensions can provide language support (syntax highlighting, LSP, formatting, linting), themes, icon themes, snippets, keymaps, and more. |
| 4 | + |
| 5 | +## Repository Structure |
| 6 | + |
| 7 | +``` |
| 8 | +extensions/ |
| 9 | + bash/ |
| 10 | + extension.json # Extension manifest |
| 11 | + parser.wasm # Tree-sitter WASM grammar |
| 12 | + highlights.scm # Tree-sitter highlight queries |
| 13 | + lua/ |
| 14 | + extension.json # Extension manifest |
| 15 | + parser.wasm |
| 16 | + highlights.scm |
| 17 | + tooling.json # Platform-specific tooling (pre-built LSP, formatter, linter binaries) |
| 18 | + build.sh # Build script for tooling archives |
| 19 | + web-core/ |
| 20 | + tooling.json # Shared LSP servers for HTML/CSS/JSON/YAML |
| 21 | + build.sh |
| 22 | + BUILD.md |
| 23 | + ... |
| 24 | +registry.json # Extension registry |
| 25 | +index.json # Extension index (for marketplace) |
| 26 | +manifests.json # Combined manifests (auto-generated, do not edit manually) |
| 27 | +scripts/ # Validation and generation scripts |
| 28 | +``` |
| 29 | + |
| 30 | +- `extension.json` defines the extension manifest (category, capabilities, tool references) |
| 31 | +- `tooling.json` (optional) defines pre-built platform-specific binaries distributed as tarballs |
| 32 | +- Not every extension has a `tooling.json`. Extensions without one rely on runtime-installed tools |
| 33 | + |
| 34 | +## Adding a New Extension |
| 35 | + |
| 36 | +1. Create a folder under `extensions/` (lowercase, use underscores for multi-word names like `c_sharp`). |
| 37 | + |
| 38 | +2. Add an `extension.json` manifest: |
| 39 | + |
| 40 | +```json |
| 41 | +{ |
| 42 | + "$schema": "https://athas.dev/schemas/extension.json", |
| 43 | + "id": "athas.mylang", |
| 44 | + "name": "MyLang", |
| 45 | + "displayName": "MyLang", |
| 46 | + "version": "1.0.0", |
| 47 | + "description": "MyLang language support with syntax highlighting", |
| 48 | + "publisher": "Athas", |
| 49 | + "categories": ["Language"], |
| 50 | + "languages": [ |
| 51 | + { |
| 52 | + "id": "mylang", |
| 53 | + "extensions": [".ml"], |
| 54 | + "aliases": ["MyLang"] |
| 55 | + } |
| 56 | + ], |
| 57 | + "capabilities": { |
| 58 | + "grammar": { |
| 59 | + "wasmPath": "parser.wasm", |
| 60 | + "highlightQuery": "highlights.scm" |
| 61 | + } |
| 62 | + } |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +3. Add the required files for your extension type (e.g., `parser.wasm` and `highlights.scm` for language extensions). |
| 67 | + |
| 68 | +4. Update `registry.json` and `index.json` to include your extension. |
| 69 | + |
| 70 | +5. Regenerate `manifests.json`: |
| 71 | + ```bash |
| 72 | + bun run scripts/generate-manifests.ts |
| 73 | + ``` |
| 74 | + |
| 75 | +6. Validate your extension: |
| 76 | + ```bash |
| 77 | + bun run scripts/validate.ts |
| 78 | + ``` |
| 79 | + |
| 80 | +## Extension Manifest Format |
| 81 | + |
| 82 | +### Required Fields |
| 83 | + |
| 84 | +| Field | Type | Description | |
| 85 | +|-------|------|-------------| |
| 86 | +| `id` | string | Unique identifier (format: `publisher.name`) | |
| 87 | +| `name` | string | Short name | |
| 88 | +| `version` | string | Semver version | |
| 89 | +| `categories` | string[] | Extension categories (`Language`, `Theme`, `Snippets`, `Keymaps`, etc.) | |
| 90 | + |
| 91 | +### Categories |
| 92 | + |
| 93 | +- `Language` - Language support (grammar, LSP, formatter, linter) |
| 94 | +- `Theme` - Editor themes |
| 95 | +- `Snippets` - Code snippets |
| 96 | +- `Keymaps` - Keyboard shortcut presets |
| 97 | +- `Formatter` - Code formatters |
| 98 | +- `Linter` - Code linters |
| 99 | +- `Other` - Everything else |
| 100 | + |
| 101 | +### Language Capabilities |
| 102 | + |
| 103 | +#### Grammar |
| 104 | + |
| 105 | +```json |
| 106 | +"grammar": { |
| 107 | + "wasmPath": "parser.wasm", |
| 108 | + "highlightQuery": "highlights.scm" |
| 109 | +} |
| 110 | +``` |
| 111 | + |
| 112 | +#### LSP |
| 113 | + |
| 114 | +```json |
| 115 | +"lsp": { |
| 116 | + "name": "pyright", |
| 117 | + "runtime": "bun", |
| 118 | + "package": "pyright", |
| 119 | + "args": ["--stdio"] |
| 120 | +} |
| 121 | +``` |
| 122 | + |
| 123 | +Supported runtimes: `bun`, `python`, `go`, `binary` |
| 124 | + |
| 125 | +#### Formatter |
| 126 | + |
| 127 | +```json |
| 128 | +"formatter": { |
| 129 | + "name": "black", |
| 130 | + "runtime": "python", |
| 131 | + "package": "black", |
| 132 | + "args": ["--stdin-filename", "${file}", "-"] |
| 133 | +} |
| 134 | +``` |
| 135 | + |
| 136 | +#### Linter |
| 137 | + |
| 138 | +```json |
| 139 | +"linter": { |
| 140 | + "name": "ruff", |
| 141 | + "runtime": "python", |
| 142 | + "package": "ruff", |
| 143 | + "args": ["check", "--stdin-filename", "${file}", "--output-format", "json", "-"] |
| 144 | +} |
| 145 | +``` |
| 146 | + |
| 147 | +## Testing Locally |
| 148 | + |
| 149 | +1. Clone this repository alongside the main Athas repo: |
| 150 | + ``` |
| 151 | + athasdev/ |
| 152 | + athas/ # Main editor repo |
| 153 | + extensions/ # This repo |
| 154 | + ``` |
| 155 | + |
| 156 | +2. Serve the extensions directory locally: |
| 157 | + ```bash |
| 158 | + bunx serve . |
| 159 | + ``` |
| 160 | + |
| 161 | +3. Point the editor to your local server: |
| 162 | + ```bash |
| 163 | + VITE_PARSER_CDN_URL=http://localhost:3000/extensions bun run dev |
| 164 | + ``` |
| 165 | + |
| 166 | +## Validation |
| 167 | + |
| 168 | +```bash |
| 169 | +bun run scripts/validate.ts |
| 170 | +``` |
| 171 | + |
| 172 | +CI runs this automatically on pull requests. |
0 commit comments