Skip to content

Commit

Permalink
flox.edit command (opens manifest.toml) (#23)
Browse files Browse the repository at this point in the history
Co-authored-by: Rok Garbas <[email protected]>
  • Loading branch information
tomberek and garbas authored Jan 13, 2025
1 parent c455a2e commit b3da7bc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Flox VSCode Extention

## Quick Start
Ensure you have "Extension Test Runner" installed in your VSCode.
It should be a recommended extension for a blank VSCode installation.

```console
$ cd git clone [email protected]/flox/flox-vscode.git;
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@
"category": "Flox",
"icon": "$(trash)",
"title": "Uninstall a package"
},
{
"command": "flox.edit",
"category": "Flox",
"title": "Edit manifest.toml"
}
],
"menus": {
Expand Down Expand Up @@ -150,8 +155,8 @@
"scripts": {
"vscode:prepublish": "npm run compile",
"package": "vsce package --allow-star-activation",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"compile": "tsc -p ./ && mkdir -p out/assets && cp assets/* out/assets",
"watch": "mkdir -p out/assets && cp assets/* out/assets && tsc -watch -p ./",
"pretest": "npm run compile && npm run lint",
"lint": "eslint src",
"test": "vscode-test"
Expand Down
16 changes: 16 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,20 @@ export async function activate(context: vscode.ExtensionContext) {

});

env.registerCommand('flox.edit', async () => {
if (env.workspaceUri === undefined) {
return
}

const manifestUri = vscode.Uri.joinPath(env.workspaceUri, ".flox", "env", "manifest.toml");
env.displayMsg("Opening manifest.toml");

try {
const doc = await vscode.workspace.openTextDocument(manifestUri);
await vscode.window.showTextDocument(doc);
} catch (error) {
env.displayError(`Something went wrong when opening manifest.toml: ${error}`);
}
});

}

0 comments on commit b3da7bc

Please sign in to comment.