Skip to content

Commit

Permalink
Showing 4 changed files with 77 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,13 @@

Contributions are welcome! Please use the `discussions` tab before opening a PR.

## Roadmap

- [ ] Automatically setup SDKs based on mise tools
- [ ] Suggest to install missing tools
- [ ] UI to install tools
- ...

## Running the extension locally
Install `mise` (if you don't have it already): https://mise.jdx.dev/getting-started.html

17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -27,6 +27,16 @@ VS Code extension for [mise](https://mise.jdx.dev/)
- 📍 Quick navigation to tool definitions
- 📱 Show tools which are not installed or active
- 📦 Install/Remove/Use tools directly from the sidebar
- 🔧 Configure extensions to use tools from `mise`

<details>
<summary>Supported extensions</summary>

List of extensions that can be configured to use tools from `mise`. Search for `Mise: Configure ...` in the command palette.

- [Denoland](https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno)

</details>

### Environment Variables
- 🌍 View [mise environment variables](https://mise.jdx.dev/environments.html)
@@ -45,13 +55,6 @@ VS Code extension for [mise](https://mise.jdx.dev/)
- Found a bug? Please [open an issue](https://github.com/hverlin/mise-vscode/issues)
- Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.

## Roadmap

- [ ] Automatically setup SDKs based on mise tools
- [ ] Suggest to install missing tools
- [ ] UI to install tools
- ...

## 📄 License

This extension is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -128,6 +128,10 @@
{
"command": "mise.useTool",
"title": "Run Mise use"
},
{
"command": "mise.configureDenoPath",
"title": "Mise: Configure Deno path"
}
],
"menus": {
56 changes: 56 additions & 0 deletions src/providers/toolsProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as os from "node:os";
import * as path from "node:path";
import * as vscode from "vscode";
import { ConfigurationTarget } from "vscode";
import type { MiseService } from "../miseService";
import { logger } from "../utils/logger";

type TreeItem = SourceItem | ToolItem;

@@ -12,6 +15,40 @@ export const MISE_USE = "mise.useTool";
export const MISE_COPY_TOOL_INSTALL_PATH = "mise.copyToolInstallPath";
export const MISE_COPY_TOOL_BIN_PATH = "mise.copyToolBinPath";

async function configureExtension({
extensionName,
configKey,
configValue,
}: {
extensionName: string;
configKey: string;
configValue: string;
}) {
const extension = vscode.extensions.getExtension(extensionName);
if (!extension) {
logger.error(`Mise: Extension ${extensionName} is not installed`);
return;
}

const configuration = vscode.workspace.getConfiguration();

if (
JSON.stringify(configuration.get(configKey)) === JSON.stringify(configValue)
) {
return;
}

await configuration.update(
configKey,
configValue,
ConfigurationTarget.Workspace,
);

vscode.window.showInformationMessage(
`Mise: Extension ${extensionName} configured.\n${configKey}: ${configValue}`,
);
}

export class MiseToolsProvider implements vscode.TreeDataProvider<TreeItem> {
private _onDidChangeTreeData = new vscode.EventEmitter<
TreeItem | undefined | null | void
@@ -374,5 +411,24 @@ export function registerCommands(
);
},
),

vscode.commands.registerCommand("mise.configureDenoPath", async () => {
const tools = await toolsProvider.getTools();
const denoTool = tools.find((tool) => tool.name === "deno");
if (!denoTool) {
vscode.window.showErrorMessage("Deno is not installed");
return;
}

configureExtension({
extensionName: "denoland.vscode-deno",
configKey: "deno.path",
configValue: path.join(denoTool.install_path, "bin", "deno"),
}).catch((error) => {
logger.error(
`Failed to configure the extension denoland.vscode-deno: ${error}`,
);
});
}),
);
}

0 comments on commit 1c9e79b

Please sign in to comment.