This commit is contained in:
Corey Johnson 2025-11-04 16:25:22 -08:00
parent b651ff9583
commit e49583d959
3 changed files with 47 additions and 2 deletions

View File

@ -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)

View File

@ -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<string>('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() {}

View File

@ -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"
}
]
},