aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/extension.ts12
-rw-r--r--editors/code/src/server.ts11
2 files changed, 17 insertions, 6 deletions
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts
index 683497dfd..6637c3bf0 100644
--- a/editors/code/src/extension.ts
+++ b/editors/code/src/extension.ts
@@ -14,7 +14,7 @@ import * as events from './events';
14import * as notifications from './notifications'; 14import * as notifications from './notifications';
15import { Server } from './server'; 15import { Server } from './server';
16 16
17export function activate(context: vscode.ExtensionContext) { 17export async function activate(context: vscode.ExtensionContext) {
18 function disposeOnDeactivation(disposable: vscode.Disposable) { 18 function disposeOnDeactivation(disposable: vscode.Disposable) {
19 context.subscriptions.push(disposable); 19 context.subscriptions.push(disposable);
20 } 20 }
@@ -159,7 +159,11 @@ export function activate(context: vscode.ExtensionContext) {
159 }); 159 });
160 160
161 // Start the language server, finally! 161 // Start the language server, finally!
162 startServer(); 162 try {
163 await startServer();
164 } catch (e) {
165 vscode.window.showErrorMessage(e.message);
166 }
163 167
164 if (Server.config.displayInlayHints) { 168 if (Server.config.displayInlayHints) {
165 const hintsUpdater = new HintsUpdater(); 169 const hintsUpdater = new HintsUpdater();
@@ -204,10 +208,10 @@ export function deactivate(): Thenable<void> {
204 return Server.client.stop(); 208 return Server.client.stop();
205} 209}
206 210
207async function reloadServer(startServer: () => void) { 211async function reloadServer(startServer: () => Promise<void>) {
208 if (Server.client != null) { 212 if (Server.client != null) {
209 vscode.window.showInformationMessage('Reloading rust-analyzer...'); 213 vscode.window.showInformationMessage('Reloading rust-analyzer...');
210 await Server.client.stop(); 214 await Server.client.stop();
211 startServer(); 215 await startServer();
212 } 216 }
213} 217}
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index 7907b70bc..e717ab294 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -1,3 +1,4 @@
1import { lookpath } from 'lookpath';
1import { homedir } from 'os'; 2import { homedir } from 'os';
2import * as lc from 'vscode-languageclient'; 3import * as lc from 'vscode-languageclient';
3 4
@@ -17,7 +18,7 @@ export class Server {
17 public static config = new Config(); 18 public static config = new Config();
18 public static client: lc.LanguageClient; 19 public static client: lc.LanguageClient;
19 20
20 public static start( 21 public static async start(
21 notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]> 22 notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]>
22 ) { 23 ) {
23 // '.' Is the fallback if no folder is open 24 // '.' Is the fallback if no folder is open
@@ -27,8 +28,14 @@ export class Server {
27 folder = workspace.workspaceFolders[0].uri.fsPath.toString(); 28 folder = workspace.workspaceFolders[0].uri.fsPath.toString();
28 } 29 }
29 30
31 const command = expandPathResolving(this.config.raLspServerPath);
32 if (!(await lookpath(command))) {
33 throw new Error(
34 `Cannot find rust-analyzer server \`${command}\` in PATH.`
35 );
36 }
30 const run: lc.Executable = { 37 const run: lc.Executable = {
31 command: expandPathResolving(this.config.raLspServerPath), 38 command,
32 options: { cwd: folder } 39 options: { cwd: folder }
33 }; 40 };
34 const serverOptions: lc.ServerOptions = { 41 const serverOptions: lc.ServerOptions = {