diff --git a/vscode-extension/README.md b/vscode-extension/README.md index 9c87c8e..7218f5c 100644 --- a/vscode-extension/README.md +++ b/vscode-extension/README.md @@ -6,7 +6,7 @@ Language support for Shrimp in VSCode. This README is for probablycorey and defu - Syntax highlighting and semantic tokens - Language server with error diagnostics -- Commands: "Show Parse Tree" (Alt+K Alt+I) and "Show Bytecode" (Alt+K Alt+,) +- Commands: "Show Parse Tree" (Alt+K Alt+I), "Show Bytecode" (Alt+K Alt+,), and "Run File" (Cmd+R) - `.sh` file association ## Development Workflow @@ -45,5 +45,5 @@ Both compile to their respective `dist/` folders. **Other features:** - [ ] Better syntax coloring -- [ ] Run shortcut - command to execute the current Shrimp file - [ ] REPL integration +- [ ] Bundle shrimp binary with extension (currently uses `shrimp.binaryPath` setting) diff --git a/vscode-extension/client/src/extension.ts b/vscode-extension/client/src/extension.ts index 7b32915..70d7c6b 100644 --- a/vscode-extension/client/src/extension.ts +++ b/vscode-extension/client/src/extension.ts @@ -69,6 +69,32 @@ export function activate(context: vscode.ExtensionContext) { await vscode.window.showTextDocument(doc, { preview: false }) }) ) + + // Command: Run File + context.subscriptions.push( + vscode.commands.registerCommand('shrimp.run', async () => { + const editor = vscode.window.activeTextEditor + if (!editor || editor.document.languageId !== 'shrimp') { + vscode.window.showErrorMessage('No active Shrimp file') + return + } + + // Auto-save before running + await editor.document.save() + + // Get binary path from settings + const config = vscode.workspace.getConfiguration('shrimp') + const binaryPath = config.get('binaryPath', 'shrimp') + + // Get the file path + const filePath = editor.document.uri.fsPath + + // Create or show terminal + const terminal = vscode.window.createTerminal('Shrimp') + terminal.show() + terminal.sendText(`${binaryPath} "${filePath}"`) + }) + ) } export function deactivate() {} diff --git a/vscode-extension/package.json b/vscode-extension/package.json index e0f53ea..2bc3b25 100644 --- a/vscode-extension/package.json +++ b/vscode-extension/package.json @@ -29,6 +29,16 @@ "editor.semanticHighlighting.enabled": true } }, + "configuration": { + "title": "Shrimp", + "properties": { + "shrimp.binaryPath": { + "type": "string", + "default": "shrimp", + "description": "Path to the shrimp binary" + } + } + }, "commands": [ { "command": "shrimp.showParseTree", @@ -37,6 +47,10 @@ { "command": "shrimp.showBytecode", "title": "Shrimp: Show Bytecode" + }, + { + "command": "shrimp.run", + "title": "Shrimp: Run File" } ], "keybindings": [ @@ -49,6 +63,11 @@ "command": "shrimp.showBytecode", "key": "alt+k alt+,", "when": "editorLangId == shrimp" + }, + { + "command": "shrimp.run", + "key": "cmd+r", + "when": "editorLangId == shrimp" } ] },