diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-17 13:24:07 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-17 13:24:07 +0000 |
commit | 4fea5808e9209c385e915d9d060c18520ce081b3 (patch) | |
tree | b1b3be960ba393200c6676fa096f8c1e12e64cc2 /editors/code/src/main.ts | |
parent | 6167101302bcc2d7f1a345e0ee44e1411056b4b3 (diff) | |
parent | 3717b0e03f2336dcccea34c5a362b20966151b18 (diff) |
Merge #3191
3191: Remove two stage constuction r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r-- | editors/code/src/main.ts | 18 |
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'; | |||
5 | import { activateStatusDisplay } from './status_display'; | 5 | import { activateStatusDisplay } from './status_display'; |
6 | import { Ctx } from './ctx'; | 6 | import { Ctx } from './ctx'; |
7 | import { activateHighlighting } from './highlighting'; | 7 | import { activateHighlighting } from './highlighting'; |
8 | import { ensureServerBinary } from './installation/server'; | ||
9 | import { Config } from './config'; | ||
8 | 10 | ||
9 | let ctx: Ctx | undefined; | 11 | let ctx: Ctx | undefined; |
10 | 12 | ||
11 | export async function activate(context: vscode.ExtensionContext) { | 13 | export 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) => { |