diff --git a/package.json b/package.json index 0a9da3e..7ab1ee8 100644 --- a/package.json +++ b/package.json @@ -425,6 +425,10 @@ "command": "mise.setEnvVariable", "title": "Mise: Set Environment Variable", "icon": "$(add)" + }, + { + "command": "mise.fmt", + "title": "Mise: Run mise fmt" } ], "menus": { diff --git a/src/commands.ts b/src/commands.ts index 990ab77..eb0efef 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -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"; diff --git a/src/miseExtension.ts b/src/miseExtension.ts index c5af38a..1830476 100644 --- a/src/miseExtension.ts +++ b/src/miseExtension.ts @@ -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, @@ -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 () => { diff --git a/src/miseService.ts b/src/miseService.ts index df4ff65..aa493c9 100644 --- a/src/miseService.ts +++ b/src/miseService.ts @@ -462,6 +462,10 @@ export class MiseService { } } + async miseFmt() { + await this.execMiseCommand("fmt", { setMiseEnv: false }); + } + async runTask(taskName: string, ...args: string[]): Promise { const terminal = this.getOrCreateTerminal("Mise run"); terminal.show();