Remove two stage constuction

This commit is contained in:
Aleksey Kladov 2020-02-17 14:11:01 +01:00
parent 978bea2b31
commit 89afb1a841
2 changed files with 15 additions and 21 deletions

View file

@ -6,13 +6,14 @@ import { activateStatusDisplay } from './status_display';
import { Ctx } from './ctx';
import { activateHighlighting } from './highlighting';
import { ensureServerBinary } from './installation/server';
import { Config } from './config';
let ctx: Ctx | undefined;
export async function activate(context: vscode.ExtensionContext) {
ctx = new Ctx(context);
const config = new Config(context)
const serverPath = await ensureServerBinary(ctx.config.serverSource);
const serverPath = await ensureServerBinary(config.serverSource);
if (serverPath == null) {
throw new Error(
"Rust Analyzer Language Server is not available. " +
@ -24,11 +25,7 @@ export async function activate(context: vscode.ExtensionContext) {
// registers its `onDidChangeDocument` handler before us.
//
// This a horribly, horribly wrong way to deal with this problem.
try {
await ctx.startServer(serverPath);
} catch (e) {
vscode.window.showErrorMessage(e.message);
}
ctx = await Ctx.create(config, context, serverPath);
// Commands which invokes manually via command palette, shortcut, etc.
ctx.registerCommand('reload', (ctx) => {