Skip to content

Commit 3423b3a

Browse files
authored
Merge pull request #403 from intersystems-community/language-server-prompt
added prompt to install language-server extension
2 parents e071753 + bf11aea commit 3423b3a

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

src/extension.ts

Lines changed: 32 additions & 5 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+
`Install the [InterSystems Language Server extension](https://marketplace.visualstudio.com/items?itemName=${extId}) for best handling of ObjectScript code.`,
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,10 +560,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
534560
outputChannel.show(true);
535561
}
536562

537-
const languageServerExt = languageServer();
563+
const languageServerExt =
564+
context.extensionMode && context.extensionMode !== vscode.ExtensionMode.Test ? await languageServer() : null;
538565
const noLSsubscriptions: { dispose(): any }[] = [];
539566
if (!languageServerExt) {
540-
outputChannel.appendLine(`The language-server extension was not found.\n`);
567+
outputChannel.appendLine(`The intersystems.language-server extension is not installed or has been disabled.\n`);
541568
outputChannel.show(true);
542569

543570
if (vscode.window.activeTextEditor) {

0 commit comments

Comments
 (0)