aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/code/package-lock.json5
-rw-r--r--editors/code/package.json1
-rw-r--r--editors/code/src/extension.ts12
-rw-r--r--editors/code/src/server.ts11
4 files changed, 23 insertions, 6 deletions
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json
index 2ceac60a0..099aaaaa2 100644
--- a/editors/code/package-lock.json
+++ b/editors/code/package-lock.json
@@ -763,6 +763,11 @@
763 "chalk": "^2.0.1" 763 "chalk": "^2.0.1"
764 } 764 }
765 }, 765 },
766 "lookpath": {
767 "version": "1.0.3",
768 "resolved": "https://registry.npmjs.org/lookpath/-/lookpath-1.0.3.tgz",
769 "integrity": "sha512-XIdgzlX26g10XnzyZdO/4obybEmfGnZyWQZ2DgmmEfVB79X+n3lhUoIzMe501C6s7RmCpAo66OPegWc+CsxYMg=="
770 },
766 "magic-string": { 771 "magic-string": {
767 "version": "0.25.3", 772 "version": "0.25.3",
768 "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.3.tgz", 773 "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.3.tgz",
diff --git a/editors/code/package.json b/editors/code/package.json
index 94887674b..5dea8fac0 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -31,6 +31,7 @@
31 "singleQuote": true 31 "singleQuote": true
32 }, 32 },
33 "dependencies": { 33 "dependencies": {
34 "lookpath": "^1.0.3",
34 "seedrandom": "^3.0.1", 35 "seedrandom": "^3.0.1",
35 "vscode-languageclient": "^5.3.0-next.4" 36 "vscode-languageclient": "^5.3.0-next.4"
36 }, 37 },
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 = {