-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from atomiechen/dev
Bump version to 0.1.3
- Loading branch information
Showing
14 changed files
with
519 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
|
||
export function registerCommandCreate(context: vscode.ExtensionContext) { | ||
let disposableCreateHprompt = vscode.commands.registerCommand('handyllm.createHprompt', function () { | ||
vscode.workspace.openTextDocument({ | ||
content: '---\n# add YAML frontmatter data here\n\n---\n\n$system$\nYou are a helpful assistant.\n\n$user$\nPlace you instructions here.\n\n', | ||
language: 'hprompt' // set the language mode to hprompt | ||
}).then(document => { | ||
vscode.window.showTextDocument(document); | ||
}); | ||
}); | ||
|
||
context.subscriptions.push(disposableCreateHprompt); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
|
||
function getOrCreateTerminal(name: string): vscode.Terminal { | ||
// check if the terminal already exists | ||
const existingTerminal = vscode.window.terminals.find(terminal => terminal.name === name); | ||
if (existingTerminal) { | ||
return existingTerminal; | ||
} else { | ||
return vscode.window.createTerminal(name); | ||
} | ||
} | ||
|
||
export function registerCommandRun(context: vscode.ExtensionContext) { | ||
// The command has been defined in the package.json file | ||
// Now provide the implementation of the command with registerCommand | ||
// The commandId parameter must match the command field in package.json | ||
let disposableRunHprompt = vscode.commands.registerCommand('handyllm.runHprompt', (uri: vscode.Uri) => { | ||
let filePath = undefined; | ||
if (uri) { | ||
filePath = uri.fsPath; | ||
} else { | ||
const activeEditor = vscode.window.activeTextEditor; | ||
if (activeEditor) { | ||
// get the file path of the currently active file | ||
filePath = activeEditor.document.uri.fsPath; | ||
} | ||
} | ||
if (filePath) { | ||
// get handyllm command name from the settings | ||
let handyllmCommand = vscode.workspace.getConfiguration().get('handyllm.commandName', 'handyllm').trim(); | ||
if (handyllmCommand === '') { | ||
handyllmCommand = 'handyllm'; | ||
} | ||
// get or create a terminal with the name "hprompt" | ||
const terminal = getOrCreateTerminal("hprompt"); | ||
terminal.show(true); | ||
// run the hprompt command in the terminal | ||
terminal.sendText(`${handyllmCommand} hprompt ${filePath}`); | ||
} else { | ||
// Display a message box to the user | ||
vscode.window.showErrorMessage('No active editor found!'); | ||
} | ||
}); | ||
|
||
context.subscriptions.push(disposableRunHprompt); | ||
} |
Oops, something went wrong.