|
| 1 | +<!-- |
| 2 | +SPDX-License-Identifier: PMPL-1.0-or-later |
| 3 | +--> |
| 4 | + |
| 5 | +# WokeLang for Visual Studio Code |
| 6 | + |
| 7 | +Official VS Code extension for WokeLang - a human-centered programming language with consent-driven capabilities. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Syntax Highlighting** - Full syntax highlighting for `.woke` files |
| 12 | +- **Auto-Completion** - Intelligent code completion for: |
| 13 | + - Keywords (to, give, remember, when, attempt, worker, etc.) |
| 14 | + - Standard library modules (std.math, std.string, std.array, etc.) |
| 15 | + - Standard library functions (55+ functions with signatures) |
| 16 | + - Local variables and functions (from type inference) |
| 17 | +- **Hover Documentation** - Rich markdown documentation on hover |
| 18 | + - Keyword explanations with syntax examples |
| 19 | + - Type information for variables and functions |
| 20 | + - Function signatures for stdlib functions |
| 21 | +- **Go-to-Definition** - Jump to definition with F12 or Cmd+Click |
| 22 | + - Functions, types, constants, variables |
| 23 | + - Nested scope support |
| 24 | +- **Real-time Diagnostics** - Instant error detection |
| 25 | + - Lexer errors (syntax errors) |
| 26 | + - Parser errors (structural errors) |
| 27 | + - Linter warnings (code quality) |
| 28 | +- **Document Formatting** - Format code with Shift+Alt+F |
| 29 | + - Consistent indentation |
| 30 | + - AST-based formatting |
| 31 | + |
| 32 | +## Installation |
| 33 | + |
| 34 | +### Prerequisites |
| 35 | + |
| 36 | +1. Install WokeLang and build the LSP server: |
| 37 | + ```bash |
| 38 | + cd /path/to/wokelang |
| 39 | + cargo build --bin woke-lsp --release |
| 40 | + ``` |
| 41 | + |
| 42 | +2. Make `woke-lsp` available in your PATH, or note the full path to the binary. |
| 43 | + |
| 44 | +### Install Extension |
| 45 | + |
| 46 | +**Option 1: From Source** |
| 47 | +```bash |
| 48 | +cd /path/to/wokelang/editors/vscode |
| 49 | +npm install |
| 50 | +npm run compile |
| 51 | +code --install-extension . |
| 52 | +``` |
| 53 | + |
| 54 | +**Option 2: Copy to Extensions Directory** |
| 55 | +```bash |
| 56 | +cp -r /path/to/wokelang/editors/vscode ~/.vscode/extensions/wokelang-0.1.0/ |
| 57 | +``` |
| 58 | + |
| 59 | +## Configuration |
| 60 | + |
| 61 | +Open VS Code settings (Cmd+,) and configure: |
| 62 | + |
| 63 | +```json |
| 64 | +{ |
| 65 | + "wokelang.serverPath": "/path/to/woke-lsp", |
| 66 | + "wokelang.trace.server": "off" |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +### Settings |
| 71 | + |
| 72 | +- `wokelang.serverPath` - Path to the `woke-lsp` executable (default: `woke-lsp`) |
| 73 | +- `wokelang.trace.server` - LSP server logging level: |
| 74 | + - `off` - No logging (default) |
| 75 | + - `messages` - Log messages only |
| 76 | + - `verbose` - Verbose logging |
| 77 | + |
| 78 | +## Usage |
| 79 | + |
| 80 | +1. Open a `.woke` file in VS Code |
| 81 | +2. The WokeLang LSP server will start automatically |
| 82 | +3. You'll see "WokeLang LSP connected" in the status bar |
| 83 | + |
| 84 | +### Features in Action |
| 85 | + |
| 86 | +**Auto-Completion:** |
| 87 | +- Type `std.` → See all stdlib modules |
| 88 | +- Type `std.math.` → See all math functions |
| 89 | +- Type `rem` → See `remember` keyword suggestion |
| 90 | + |
| 91 | +**Hover:** |
| 92 | +- Hover over `to` → See function definition syntax |
| 93 | +- Hover over a variable → See its inferred type |
| 94 | + |
| 95 | +**Go-to-Definition:** |
| 96 | +- Press F12 on a function call → Jump to function definition |
| 97 | +- Cmd+Click on a variable → Jump to declaration |
| 98 | + |
| 99 | +**Formatting:** |
| 100 | +- Press Shift+Alt+F → Format entire document |
| 101 | + |
| 102 | +## Example |
| 103 | + |
| 104 | +```wokelang |
| 105 | +// Define a function |
| 106 | +to calculateArea(width, height) { |
| 107 | + give back width * height; |
| 108 | +} |
| 109 | +
|
| 110 | +// Use standard library |
| 111 | +to main() { |
| 112 | + remember result = calculateArea(5, 10); |
| 113 | + remember rounded = std.math.round(3.7); |
| 114 | +
|
| 115 | + when result > 20 { |
| 116 | + print("Large area"); |
| 117 | + } otherwise { |
| 118 | + print("Small area"); |
| 119 | + } |
| 120 | +} |
| 121 | +``` |
| 122 | + |
| 123 | +## Troubleshooting |
| 124 | + |
| 125 | +### Extension Not Activating |
| 126 | +- Ensure the file has `.woke` extension |
| 127 | +- Check that `woke-lsp` is in your PATH or configured in settings |
| 128 | + |
| 129 | +### No Completions/Hover |
| 130 | +- Check the Output panel (View → Output → WokeLang Language Server) |
| 131 | +- Verify `woke-lsp` is running: `ps aux | grep woke-lsp` |
| 132 | + |
| 133 | +### Server Crashes |
| 134 | +- Check LSP server logs for errors |
| 135 | +- Try increasing trace level: `"wokelang.trace.server": "verbose"` |
| 136 | + |
| 137 | +## Development |
| 138 | + |
| 139 | +### Build Extension |
| 140 | +```bash |
| 141 | +cd editors/vscode |
| 142 | +npm install |
| 143 | +npm run compile |
| 144 | +``` |
| 145 | + |
| 146 | +### Watch Mode (for development) |
| 147 | +```bash |
| 148 | +npm run watch |
| 149 | +``` |
| 150 | + |
| 151 | +### Package Extension |
| 152 | +```bash |
| 153 | +npm install -g vsce |
| 154 | +vsce package |
| 155 | +``` |
| 156 | + |
| 157 | +This creates `wokelang-0.1.0.vsix` that can be installed with: |
| 158 | +```bash |
| 159 | +code --install-extension wokelang-0.1.0.vsix |
| 160 | +``` |
| 161 | + |
| 162 | +## License |
| 163 | + |
| 164 | +PMPL-1.0-or-later |
| 165 | + |
| 166 | +## Links |
| 167 | + |
| 168 | +- [WokeLang Repository](https://github.com/hyperpolymath/wokelang) |
| 169 | +- [Report Issues](https://github.com/hyperpolymath/wokelang/issues) |
| 170 | +- [Documentation](https://wokelang.org) |
| 171 | + |
| 172 | +## Credits |
| 173 | + |
| 174 | +**Author:** Jonathan D.A. Jewell <jonathan.jewell@open.ac.uk> |
| 175 | +**Co-Authored-By:** Claude Sonnet 4.5 <noreply@anthropic.com> |
0 commit comments