aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r--editors/code/src/main.ts18
1 files changed, 12 insertions, 6 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 0bf2c4829..0ad7ef1bb 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -5,21 +5,27 @@ import { activateInlayHints } from './inlay_hints';
5import { activateStatusDisplay } from './status_display'; 5import { activateStatusDisplay } from './status_display';
6import { Ctx } from './ctx'; 6import { Ctx } from './ctx';
7import { activateHighlighting } from './highlighting'; 7import { activateHighlighting } from './highlighting';
8import { ensureServerBinary } from './installation/server';
9import { Config } from './config';
8 10
9let ctx: Ctx | undefined; 11let ctx: Ctx | undefined;
10 12
11export async function activate(context: vscode.ExtensionContext) { 13export async function activate(context: vscode.ExtensionContext) {
12 ctx = new Ctx(context); 14 const config = new Config(context)
15
16 const serverPath = await ensureServerBinary(config.serverSource);
17 if (serverPath == null) {
18 throw new Error(
19 "Rust Analyzer Language Server is not available. " +
20 "Please, ensure its [proper installation](https://rust-analyzer.github.io/manual.html#installation)."
21 );
22 }
13 23
14 // Note: we try to start the server before we activate type hints so that it 24 // Note: we try to start the server before we activate type hints so that it
15 // registers its `onDidChangeDocument` handler before us. 25 // registers its `onDidChangeDocument` handler before us.
16 // 26 //
17 // This a horribly, horribly wrong way to deal with this problem. 27 // This a horribly, horribly wrong way to deal with this problem.
18 try { 28 ctx = await Ctx.create(config, context, serverPath);
19 await ctx.startServer();
20 } catch (e) {
21 vscode.window.showErrorMessage(e.message);
22 }
23 29
24 // Commands which invokes manually via command palette, shortcut, etc. 30 // Commands which invokes manually via command palette, shortcut, etc.
25 ctx.registerCommand('reload', (ctx) => { 31 ctx.registerCommand('reload', (ctx) => {