aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/src/installation/language_server.ts56
1 files changed, 30 insertions, 26 deletions
diff --git a/editors/code/src/installation/language_server.ts b/editors/code/src/installation/language_server.ts
index ea1228e46..e571cbc98 100644
--- a/editors/code/src/installation/language_server.ts
+++ b/editors/code/src/installation/language_server.ts
@@ -71,9 +71,10 @@ export async function ensureLanguageServerBinary(
71 if (isBinaryAvailable(langServerSource.path)) { 71 if (isBinaryAvailable(langServerSource.path)) {
72 return langServerSource.path; 72 return langServerSource.path;
73 } 73 }
74
74 vscode.window.showErrorMessage( 75 vscode.window.showErrorMessage(
75 `Unable to run ${langServerSource.path} binary. ` + 76 `Unable to run ${langServerSource.path} binary. ` +
76 "To use the pre-built language server, set `rust-analyzer.raLspServerPath` " + 77 `To use the pre-built language server, set "rust-analyzer.raLspServerPath" ` +
77 "value to `null` or remove it from the settings to use it by default." 78 "value to `null` or remove it from the settings to use it by default."
78 ); 79 );
79 return null; 80 return null;
@@ -81,34 +82,37 @@ export async function ensureLanguageServerBinary(
81 case BinarySource.Type.GithubRelease: { 82 case BinarySource.Type.GithubRelease: {
82 const prebuiltBinaryPath = path.join(langServerSource.dir, langServerSource.file); 83 const prebuiltBinaryPath = path.join(langServerSource.dir, langServerSource.file);
83 84
84 if (!isBinaryAvailable(prebuiltBinaryPath)) { 85 if (isBinaryAvailable(prebuiltBinaryPath)) {
85 const userResponse = await vscode.window.showInformationMessage( 86 return prebuiltBinaryPath;
86 "Language server binary for rust-analyzer was not found. " + 87 }
87 "Do you want to download it now?",
88 "Download now", "Cancel"
89 );
90 if (userResponse !== "Download now") return null;
91
92 try {
93 await downloadLatestLanguageServer(langServerSource);
94 } catch (err) {
95 await vscode.window.showErrorMessage(
96 `Failed to download language server from ${langServerSource.repo.name} ` +
97 `GitHub repository: ${err.message}`
98 );
99 return null;
100 }
101
102
103 assert(
104 isBinaryAvailable(prebuiltBinaryPath),
105 "Downloaded language server binary is not functional"
106 );
107 88
108 vscode.window.showInformationMessage( 89 const userResponse = await vscode.window.showInformationMessage(
109 "Rust analyzer language server was successfully installed 🦀" 90 "Language server binary for rust-analyzer was not found. " +
91 "Do you want to download it now?",
92 "Download now", "Cancel"
93 );
94 if (userResponse !== "Download now") return null;
95
96 try {
97 await downloadLatestLanguageServer(langServerSource);
98 } catch (err) {
99 await vscode.window.showErrorMessage(
100 `Failed to download language server from ${langServerSource.repo.name} ` +
101 `GitHub repository: ${err.message}`
110 ); 102 );
103 return null;
111 } 104 }
105
106
107 assert(
108 isBinaryAvailable(prebuiltBinaryPath),
109 "Downloaded language server binary is not functional"
110 );
111
112 vscode.window.showInformationMessage(
113 "Rust analyzer language server was successfully installed 🦀"
114 );
115
112 return prebuiltBinaryPath; 116 return prebuiltBinaryPath;
113 } 117 }
114 } 118 }