summaryrefslogtreecommitdiffhomepage
path: root/sdks/vscode/src
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-07-21 19:10:51 -0400
committerFrank <[email protected]>2025-07-21 19:10:57 -0400
commit5611ef8b28216aa9dd2ceb6ed17d5779a29154f6 (patch)
treea58c6dceb5f0e6243a6cbe3e4dc87a259119fd10 /sdks/vscode/src
parentbec796e3c3c097bfc7bb9090729ec23573151d79 (diff)
downloadopencode-5611ef8b28216aa9dd2ceb6ed17d5779a29154f6.tar.gz
opencode-5611ef8b28216aa9dd2ceb6ed17d5779a29154f6.zip
wip: vscode extension
Diffstat (limited to 'sdks/vscode/src')
-rw-r--r--sdks/vscode/src/extension.ts50
1 files changed, 25 insertions, 25 deletions
diff --git a/sdks/vscode/src/extension.ts b/sdks/vscode/src/extension.ts
index a183ef09a..f4daeb10b 100644
--- a/sdks/vscode/src/extension.ts
+++ b/sdks/vscode/src/extension.ts
@@ -1,10 +1,10 @@
// This method is called when your extension is deactivated
export function deactivate() {}
-import * as vscode from "vscode"
+import * as vscode from "vscode";
export function activate(context: vscode.ExtensionContext) {
- const TERMINAL_NAME = "opencode Terminal"
+ const TERMINAL_NAME = "opencode Terminal";
// Register command to open terminal in split screen and run opencode
let openTerminalDisposable = vscode.commands.registerCommand("opencode.openTerminal", async () => {
@@ -15,56 +15,56 @@ export function activate(context: vscode.ExtensionContext) {
viewColumn: vscode.ViewColumn.Beside,
preserveFocus: false,
},
- })
+ });
- terminal.show()
- terminal.sendText("OPENCODE_THEME=system OPENCODE_CALLER=vscode opencode")
- })
+ terminal.show();
+ terminal.sendText("OPENCODE_THEME=system OPENCODE_CALLER=vscode opencode");
+ });
// Register command to add filepath to terminal
let addFilepathDisposable = vscode.commands.registerCommand("opencode.addFilepathToTerminal", async () => {
- const activeEditor = vscode.window.activeTextEditor
+ const activeEditor = vscode.window.activeTextEditor;
if (!activeEditor) {
- vscode.window.showInformationMessage("No active file to get path from")
- return
+ vscode.window.showInformationMessage("No active file to get path from");
+ return;
}
- const document = activeEditor.document
- const workspaceFolder = vscode.workspace.getWorkspaceFolder(document.uri)
+ const document = activeEditor.document;
+ const workspaceFolder = vscode.workspace.getWorkspaceFolder(document.uri);
if (!workspaceFolder) {
- vscode.window.showInformationMessage("File is not in a workspace")
- return
+ vscode.window.showInformationMessage("File is not in a workspace");
+ return;
}
// Get the relative path from workspace root
- const relativePath = vscode.workspace.asRelativePath(document.uri)
- let filepathWithAt = `@${relativePath}`
+ const relativePath = vscode.workspace.asRelativePath(document.uri);
+ let filepathWithAt = `@${relativePath}`;
// Check if there's a selection and add line numbers
- const selection = activeEditor.selection
+ const selection = activeEditor.selection;
if (!selection.isEmpty) {
// Convert to 1-based line numbers
- const startLine = selection.start.line + 1
- const endLine = selection.end.line + 1
+ const startLine = selection.start.line + 1;
+ const endLine = selection.end.line + 1;
if (startLine === endLine) {
// Single line selection
- filepathWithAt += `#L${startLine}`
+ filepathWithAt += `#L${startLine}`;
} else {
// Multi-line selection
- filepathWithAt += `#L${startLine}-${endLine}`
+ filepathWithAt += `#L${startLine}-${endLine}`;
}
}
// Get or create terminal
- let terminal = vscode.window.activeTerminal
+ let terminal = vscode.window.activeTerminal;
if (terminal?.name === TERMINAL_NAME) {
- terminal.sendText(filepathWithAt)
- terminal.show()
+ terminal.sendText(filepathWithAt);
+ terminal.show();
}
- })
+ });
- context.subscriptions.push(openTerminalDisposable, addFilepathDisposable)
+ context.subscriptions.push(openTerminalDisposable, addFilepathDisposable);
}