summaryrefslogtreecommitdiffhomepage
path: root/sdks/vscode
diff options
context:
space:
mode:
Diffstat (limited to 'sdks/vscode')
-rw-r--r--sdks/vscode/images/button-dark.svg4
-rw-r--r--sdks/vscode/images/button-light.svg4
-rw-r--r--sdks/vscode/package.json15
-rw-r--r--sdks/vscode/src/extension.ts50
4 files changed, 47 insertions, 26 deletions
diff --git a/sdks/vscode/images/button-dark.svg b/sdks/vscode/images/button-dark.svg
new file mode 100644
index 000000000..404e214d5
--- /dev/null
+++ b/sdks/vscode/images/button-dark.svg
@@ -0,0 +1,4 @@
+<svg width="70" height="70" viewBox="0 0 70 70" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M0 13H35V58H0V13ZM26.25 22.1957H8.75V48.701H26.25V22.1957Z" fill="black"/>
+<path d="M43.75 13H70V22.1957H52.5V48.701H70V57.8967H43.75V13Z" fill="black"/>
+</svg>
diff --git a/sdks/vscode/images/button-light.svg b/sdks/vscode/images/button-light.svg
new file mode 100644
index 000000000..a309fcaed
--- /dev/null
+++ b/sdks/vscode/images/button-light.svg
@@ -0,0 +1,4 @@
+<svg width="70" height="70" viewBox="0 0 70 70" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M0 13H35V58H0V13ZM26.25 22.1957H8.75V48.701H26.25V22.1957Z" fill="white"/>
+<path d="M43.75 13H70V22.1957H52.5V48.701H70V57.8967H43.75V13Z" fill="white"/>
+</svg>
diff --git a/sdks/vscode/package.json b/sdks/vscode/package.json
index b2e1135b2..c034d5880 100644
--- a/sdks/vscode/package.json
+++ b/sdks/vscode/package.json
@@ -26,13 +26,26 @@
"commands": [
{
"command": "opencode.openTerminal",
- "title": "Open Terminal with Opencode"
+ "title": "Open Terminal with Opencode",
+ "icon": {
+ "light": "images/button-dark.svg",
+ "dark": "images/button-light.svg"
+ }
},
{
"command": "opencode.addFilepathToTerminal",
"title": "Add Filepath to Terminal"
}
],
+ "menus": {
+ "editor/title": [
+ {
+ "command": "opencode.openTerminal",
+ "when": "editorTextFocus",
+ "group": "navigation"
+ }
+ ]
+ },
"keybindings": [
{
"command": "opencode.openTerminal",
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);
}