Skip to content

Commit

Permalink
feat: Add mise fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
hverlin committed Dec 23, 2024
1 parent e742e6f commit 5e9be2e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@
"command": "mise.setEnvVariable",
"title": "Mise: Set Environment Variable",
"icon": "$(add)"
},
{
"command": "mise.fmt",
"title": "Mise: Run mise fmt"
}
],
"menus": {
Expand Down
1 change: 1 addition & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export const MISE_RUN_TASK = "mise.runTask";
export const MISE_SET_ENV_VARIABLE = "mise.setEnvVariable";
export const MISE_USE_TOOL = "mise.useTool";
export const MISE_WATCH_TASK = "mise.watchTask";
export const MISE_FMT = "mise.fmt";
7 changes: 7 additions & 0 deletions src/miseExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createCache } from "async-cache-dedupe";
import vscode, { MarkdownString } from "vscode";
import {
MISE_CONFIGURE_ALL_SKD_PATHS,
MISE_FMT,
MISE_INSTALL_ALL,
MISE_LIST_ALL_TOOLS,
MISE_OPEN_EXTENSION_SETTINGS,
Expand Down Expand Up @@ -318,6 +319,12 @@ export class MiseExtension {
createHoverProvider(allTomlFilesSelector, this.miseService),
);

context.subscriptions.push(
vscode.commands.registerCommand(MISE_FMT, () => {
this.miseService.miseFmt();
}),
);

await vscode.commands.executeCommand(MISE_RELOAD);

setTimeout(async () => {
Expand Down
4 changes: 4 additions & 0 deletions src/miseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ export class MiseService {
}
}

async miseFmt() {
await this.execMiseCommand("fmt", { setMiseEnv: false });
}

async runTask(taskName: string, ...args: string[]): Promise<void> {
const terminal = this.getOrCreateTerminal("Mise run");
terminal.show();
Expand Down

0 comments on commit 5e9be2e

Please sign in to comment.