Skip to content

Commit ef91a30

Browse files
committed
added prompt to install language-server extension
1 parent e071753 commit ef91a30

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

src/extension.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ async function serverManager(): Promise<any> {
342342
}
343343
await vscode.window
344344
.showInformationMessage(
345-
"The [InterSystems® Server Manager extension](https://marketplace.visualstudio.com/items?itemName=intersystems-community.servermanager) is recommended to help you [define connections and store passwords securely](https://intersystems-community.github.io/vscode-objectscript/configuration/#configuring-a-server) in your keychain.",
345+
`The [InterSystems® Server Manager extension](https://marketplace.visualstudio.com/items?itemName=${extId}) is recommended to help you [define connections and store passwords securely](https://intersystems-community.github.io/vscode-objectscript/configuration/#configuring-a-server) in your keychain.`,
346346
"Install",
347347
"Later",
348348
"Never"
@@ -370,9 +370,35 @@ async function serverManager(): Promise<any> {
370370
}
371371
}
372372

373-
function languageServer(): vscode.Extension<any> {
373+
async function languageServer(): Promise<vscode.Extension<any>> {
374374
const extId = "intersystems.language-server";
375-
const extension = vscode.extensions.getExtension(extId);
375+
let extension = vscode.extensions.getExtension(extId);
376+
377+
if (!extension) {
378+
try {
379+
await vscode.commands.executeCommand("extension.open", extId);
380+
} catch (ex) {
381+
// Such command do not exists, suppose we are under Theia, it's not possible to install this extension this way
382+
return;
383+
}
384+
await vscode.window
385+
.showInformationMessage(
386+
`The [InterSystems® Language-Server extension](https://marketplace.visualstudio.com/items?itemName=${extId}) is recommended.`,
387+
"Install",
388+
"Later"
389+
)
390+
.then(async (action) => {
391+
switch (action) {
392+
case "Install":
393+
await vscode.commands.executeCommand("workbench.extensions.search", `@tag:"intersystems"`).then(null, null);
394+
await vscode.commands.executeCommand("workbench.extensions.installExtension", extId);
395+
extension = vscode.extensions.getExtension(extId);
396+
break;
397+
case "Later":
398+
default:
399+
}
400+
});
401+
}
376402

377403
return extension;
378404
}
@@ -534,7 +560,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
534560
outputChannel.show(true);
535561
}
536562

537-
const languageServerExt = languageServer();
563+
const languageServerExt = await languageServer();
538564
const noLSsubscriptions: { dispose(): any }[] = [];
539565
if (!languageServerExt) {
540566
outputChannel.appendLine(`The language-server extension was not found.\n`);

0 commit comments

Comments
 (0)