Skip to content

Commit

Permalink
move command registration inside activate
Browse files Browse the repository at this point in the history
  • Loading branch information
nhedger committed Nov 5, 2023
1 parent 154d797 commit acb62f2
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,6 @@ const resolveAsync = promisify<string, resolve.AsyncOpts, string | undefined>(

let client: LanguageClient;

commands.registerCommand(Commands.StopServer, async () => {
if (!client) {
return;
}
try {
await client.stop();
} catch (error) {
client.error("Stopping client failed", error, "force");
}
});

commands.registerCommand(Commands.RestartLspServer, async () => {
if (!client) {
return;
}
try {
if (client.isRunning()) {
await client.restart();
} else {
await client.start();
}
} catch (error) {
client.error("Restarting client failed", error, "force");
}
});

const IN_BIOME_PROJECT = "inBiomeProject";

export async function activate(context: ExtensionContext) {
Expand All @@ -72,6 +46,32 @@ export async function activate(context: ExtensionContext) {
.getConfiguration("biome")
.get<boolean>("requireConfiguration");

commands.registerCommand(Commands.StopServer, async () => {
if (!client) {
return;
}
try {
await client.stop();
} catch (error) {
client.error("Stopping client failed", error, "force");
}
});

commands.registerCommand(Commands.RestartLspServer, async () => {
if (!client) {
return;
}
try {
if (client.isRunning()) {
await client.restart();
} else {
await client.start();
}
} catch (error) {
client.error("Restarting client failed", error, "force");
}
});

commands.registerCommand("biome.clearVersionsCache", async () => {
await context.globalState.update("biome_versions_cache", undefined);
});
Expand Down

0 comments on commit acb62f2

Please sign in to comment.