diff options
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/commands/index.ts | 2 | ||||
-rw-r--r-- | editors/code/src/commands/ssr.ts | 4 | ||||
-rw-r--r-- | editors/code/src/config.ts | 42 | ||||
-rw-r--r-- | editors/code/src/highlighting.ts | 2 | ||||
-rw-r--r-- | editors/code/src/inlay_hints.ts | 8 | ||||
-rw-r--r-- | editors/code/src/installation/download_artifact.ts | 4 | ||||
-rw-r--r-- | editors/code/src/installation/fetch_artifact_release_info.ts | 6 | ||||
-rw-r--r-- | editors/code/src/installation/server.ts | 3 | ||||
-rw-r--r-- | editors/code/src/main.ts | 12 | ||||
-rw-r--r-- | editors/code/src/status_display.ts | 2 |
10 files changed, 42 insertions, 43 deletions
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index d05f40d67..bebd99ca9 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts | |||
@@ -16,7 +16,7 @@ export * from './ssr'; | |||
16 | 16 | ||
17 | export function collectGarbage(ctx: Ctx): Cmd { | 17 | export function collectGarbage(ctx: Ctx): Cmd { |
18 | return async () => { | 18 | return async () => { |
19 | ctx.client?.sendRequest<null>('rust-analyzer/collectGarbage', null); | 19 | await ctx.client?.sendRequest<null>('rust-analyzer/collectGarbage', null); |
20 | }; | 20 | }; |
21 | } | 21 | } |
22 | 22 | ||
diff --git a/editors/code/src/commands/ssr.ts b/editors/code/src/commands/ssr.ts index 6287bf47b..9b814612a 100644 --- a/editors/code/src/commands/ssr.ts +++ b/editors/code/src/commands/ssr.ts | |||
@@ -14,9 +14,9 @@ export function ssr(ctx: Ctx): Cmd { | |||
14 | if (x.includes('==>>')) { | 14 | if (x.includes('==>>')) { |
15 | return null; | 15 | return null; |
16 | } | 16 | } |
17 | return "Enter request: pattern ==>> template" | 17 | return "Enter request: pattern ==>> template"; |
18 | } | 18 | } |
19 | } | 19 | }; |
20 | const request = await vscode.window.showInputBox(options); | 20 | const request = await vscode.window.showInputBox(options); |
21 | 21 | ||
22 | if (!request) return; | 22 | if (!request) return; |
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index c3fa788c7..347c989c4 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -22,7 +22,7 @@ export class Config { | |||
22 | "cargoFeatures", | 22 | "cargoFeatures", |
23 | "cargo-watch", | 23 | "cargo-watch", |
24 | ] | 24 | ] |
25 | .map(opt => `${Config.rootSection}.${opt}`); | 25 | .map(opt => `${Config.rootSection}.${opt}`); |
26 | 26 | ||
27 | private static readonly extensionVersion: string = (() => { | 27 | private static readonly extensionVersion: string = (() => { |
28 | const packageJsonVersion = vscode | 28 | const packageJsonVersion = vscode |
@@ -76,7 +76,7 @@ export class Config { | |||
76 | } | 76 | } |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Name of the binary artifact for `ra_lsp_server` that is published for | 79 | * Name of the binary artifact for `rust-analyzer` that is published for |
80 | * `platform` on GitHub releases. (It is also stored under the same name when | 80 | * `platform` on GitHub releases. (It is also stored under the same name when |
81 | * downloaded by the extension). | 81 | * downloaded by the extension). |
82 | */ | 82 | */ |
@@ -91,12 +91,12 @@ export class Config { | |||
91 | case "arm": | 91 | case "arm": |
92 | case "arm64": return null; | 92 | case "arm64": return null; |
93 | 93 | ||
94 | default: return "ra_lsp_server-linux"; | 94 | default: return "rust-analyzer-linux"; |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | case "darwin": return "ra_lsp_server-mac"; | 98 | case "darwin": return "rust-analyzer-mac"; |
99 | case "win32": return "ra_lsp_server-windows.exe"; | 99 | case "win32": return "rust-analyzer-windows.exe"; |
100 | 100 | ||
101 | // Users on these platforms yet need to manually build from sources | 101 | // Users on these platforms yet need to manually build from sources |
102 | case "aix": | 102 | case "aix": |
@@ -111,7 +111,7 @@ export class Config { | |||
111 | } | 111 | } |
112 | 112 | ||
113 | get serverSource(): null | BinarySource { | 113 | get serverSource(): null | BinarySource { |
114 | const serverPath = RA_LSP_DEBUG ?? this.cfg.get<null | string>("raLspServerPath"); | 114 | const serverPath = RA_LSP_DEBUG ?? this.cfg.get<null | string>("serverPath"); |
115 | 115 | ||
116 | if (serverPath) { | 116 | if (serverPath) { |
117 | return { | 117 | return { |
@@ -126,7 +126,7 @@ export class Config { | |||
126 | 126 | ||
127 | return { | 127 | return { |
128 | type: BinarySource.Type.GithubRelease, | 128 | type: BinarySource.Type.GithubRelease, |
129 | dir: this.ctx.globalStoragePath, | 129 | dir: this.ctx.globalStoragePath, |
130 | file: prebuiltBinaryName, | 130 | file: prebuiltBinaryName, |
131 | storage: this.ctx.globalState, | 131 | storage: this.ctx.globalState, |
132 | version: Config.extensionVersion, | 132 | version: Config.extensionVersion, |
@@ -140,30 +140,30 @@ export class Config { | |||
140 | // We don't do runtime config validation here for simplicity. More on stackoverflow: | 140 | // We don't do runtime config validation here for simplicity. More on stackoverflow: |
141 | // https://stackoverflow.com/questions/60135780/what-is-the-best-way-to-type-check-the-configuration-for-vscode-extension | 141 | // https://stackoverflow.com/questions/60135780/what-is-the-best-way-to-type-check-the-configuration-for-vscode-extension |
142 | 142 | ||
143 | get highlightingOn() { return this.cfg.get("highlightingOn") as boolean; } | 143 | get highlightingOn() { return this.cfg.get("highlightingOn") as boolean; } |
144 | get rainbowHighlightingOn() { return this.cfg.get("rainbowHighlightingOn") as boolean; } | 144 | get rainbowHighlightingOn() { return this.cfg.get("rainbowHighlightingOn") as boolean; } |
145 | get lruCapacity() { return this.cfg.get("lruCapacity") as null | number; } | 145 | get lruCapacity() { return this.cfg.get("lruCapacity") as null | number; } |
146 | get displayInlayHints() { return this.cfg.get("displayInlayHints") as boolean; } | 146 | get displayInlayHints() { return this.cfg.get("displayInlayHints") as boolean; } |
147 | get maxInlayHintLength() { return this.cfg.get("maxInlayHintLength") as number; } | 147 | get maxInlayHintLength() { return this.cfg.get("maxInlayHintLength") as number; } |
148 | get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; } | 148 | get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; } |
149 | get useClientWatching() { return this.cfg.get("useClientWatching") as boolean; } | 149 | get useClientWatching() { return this.cfg.get("useClientWatching") as boolean; } |
150 | get featureFlags() { return this.cfg.get("featureFlags") as Record<string, boolean>; } | 150 | get featureFlags() { return this.cfg.get("featureFlags") as Record<string, boolean>; } |
151 | get rustfmtArgs() { return this.cfg.get("rustfmtArgs") as string[]; } | 151 | get rustfmtArgs() { return this.cfg.get("rustfmtArgs") as string[]; } |
152 | 152 | ||
153 | get cargoWatchOptions(): CargoWatchOptions { | 153 | get cargoWatchOptions(): CargoWatchOptions { |
154 | return { | 154 | return { |
155 | enable: this.cfg.get("cargo-watch.enable") as boolean, | 155 | enable: this.cfg.get("cargo-watch.enable") as boolean, |
156 | arguments: this.cfg.get("cargo-watch.arguments") as string[], | 156 | arguments: this.cfg.get("cargo-watch.arguments") as string[], |
157 | allTargets: this.cfg.get("cargo-watch.allTargets") as boolean, | 157 | allTargets: this.cfg.get("cargo-watch.allTargets") as boolean, |
158 | command: this.cfg.get("cargo-watch.command") as string, | 158 | command: this.cfg.get("cargo-watch.command") as string, |
159 | }; | 159 | }; |
160 | } | 160 | } |
161 | 161 | ||
162 | get cargoFeatures(): CargoFeatures { | 162 | get cargoFeatures(): CargoFeatures { |
163 | return { | 163 | return { |
164 | noDefaultFeatures: this.cfg.get("cargoFeatures.noDefaultFeatures") as boolean, | 164 | noDefaultFeatures: this.cfg.get("cargoFeatures.noDefaultFeatures") as boolean, |
165 | allFeatures: this.cfg.get("cargoFeatures.allFeatures") as boolean, | 165 | allFeatures: this.cfg.get("cargoFeatures.allFeatures") as boolean, |
166 | features: this.cfg.get("cargoFeatures.features") as string[], | 166 | features: this.cfg.get("cargoFeatures.features") as string[], |
167 | }; | 167 | }; |
168 | } | 168 | } |
169 | 169 | ||
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index a2db04de8..c4d286aef 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts | |||
@@ -29,7 +29,7 @@ export function activateHighlighting(ctx: Ctx) { | |||
29 | highlighter.setHighlights(targetEditor, params.decorations); | 29 | highlighter.setHighlights(targetEditor, params.decorations); |
30 | }, | 30 | }, |
31 | ); | 31 | ); |
32 | }; | 32 | } |
33 | 33 | ||
34 | vscode.workspace.onDidChangeConfiguration( | 34 | vscode.workspace.onDidChangeConfiguration( |
35 | _ => highlighter.removeHighlights(), | 35 | _ => highlighter.removeHighlights(), |
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts index f82df66ae..26705067a 100644 --- a/editors/code/src/inlay_hints.ts +++ b/editors/code/src/inlay_hints.ts | |||
@@ -29,13 +29,13 @@ export function activateInlayHints(ctx: Ctx) { | |||
29 | 29 | ||
30 | ctx.pushCleanup({ | 30 | ctx.pushCleanup({ |
31 | dispose() { | 31 | dispose() { |
32 | hintsUpdater.clear() | 32 | hintsUpdater.clear(); |
33 | } | 33 | } |
34 | }) | 34 | }); |
35 | 35 | ||
36 | // XXX: we don't await this, thus Promise rejections won't be handled, but | 36 | // XXX: we don't await this, thus Promise rejections won't be handled, but |
37 | // this should never throw in fact... | 37 | // this should never throw in fact... |
38 | hintsUpdater.setEnabled(ctx.config.displayInlayHints) | 38 | void hintsUpdater.setEnabled(ctx.config.displayInlayHints); |
39 | } | 39 | } |
40 | 40 | ||
41 | interface InlayHintsParams { | 41 | interface InlayHintsParams { |
@@ -57,7 +57,7 @@ const typeHintDecorationType = vscode.window.createTextEditorDecorationType({ | |||
57 | const parameterHintDecorationType = vscode.window.createTextEditorDecorationType({ | 57 | const parameterHintDecorationType = vscode.window.createTextEditorDecorationType({ |
58 | before: { | 58 | before: { |
59 | color: new vscode.ThemeColor('rust_analyzer.inlayHint'), | 59 | color: new vscode.ThemeColor('rust_analyzer.inlayHint'), |
60 | } | 60 | }, |
61 | }); | 61 | }); |
62 | 62 | ||
63 | class HintsUpdater { | 63 | class HintsUpdater { |
diff --git a/editors/code/src/installation/download_artifact.ts b/editors/code/src/installation/download_artifact.ts index de655f8f4..9996c556f 100644 --- a/editors/code/src/installation/download_artifact.ts +++ b/editors/code/src/installation/download_artifact.ts | |||
@@ -15,7 +15,7 @@ import { throttle } from "throttle-debounce"; | |||
15 | * of the artifact as `displayName`. | 15 | * of the artifact as `displayName`. |
16 | */ | 16 | */ |
17 | export async function downloadArtifact( | 17 | export async function downloadArtifact( |
18 | {downloadUrl, releaseName}: ArtifactReleaseInfo, | 18 | { downloadUrl, releaseName }: ArtifactReleaseInfo, |
19 | artifactFileName: string, | 19 | artifactFileName: string, |
20 | installationDir: string, | 20 | installationDir: string, |
21 | displayName: string, | 21 | displayName: string, |
@@ -23,7 +23,7 @@ export async function downloadArtifact( | |||
23 | await fs.mkdir(installationDir).catch(err => assert.strictEqual( | 23 | await fs.mkdir(installationDir).catch(err => assert.strictEqual( |
24 | err?.code, | 24 | err?.code, |
25 | "EEXIST", | 25 | "EEXIST", |
26 | `Couldn't create directory "${installationDir}" to download `+ | 26 | `Couldn't create directory "${installationDir}" to download ` + |
27 | `${artifactFileName} artifact: ${err.message}` | 27 | `${artifactFileName} artifact: ${err.message}` |
28 | )); | 28 | )); |
29 | 29 | ||
diff --git a/editors/code/src/installation/fetch_artifact_release_info.ts b/editors/code/src/installation/fetch_artifact_release_info.ts index 7d497057a..71889e82a 100644 --- a/editors/code/src/installation/fetch_artifact_release_info.ts +++ b/editors/code/src/installation/fetch_artifact_release_info.ts | |||
@@ -14,7 +14,7 @@ export async function fetchArtifactReleaseInfo( | |||
14 | ): Promise<null | ArtifactReleaseInfo> { | 14 | ): Promise<null | ArtifactReleaseInfo> { |
15 | 15 | ||
16 | const repoOwner = encodeURIComponent(repo.owner); | 16 | const repoOwner = encodeURIComponent(repo.owner); |
17 | const repoName = encodeURIComponent(repo.name); | 17 | const repoName = encodeURIComponent(repo.name); |
18 | 18 | ||
19 | const apiEndpointPath = releaseTag | 19 | const apiEndpointPath = releaseTag |
20 | ? `/repos/${repoOwner}/${repoName}/releases/tags/${releaseTag}` | 20 | ? `/repos/${repoOwner}/${repoName}/releases/tags/${releaseTag}` |
@@ -28,8 +28,8 @@ export async function fetchArtifactReleaseInfo( | |||
28 | 28 | ||
29 | // FIXME: handle non-ok response | 29 | // FIXME: handle non-ok response |
30 | const response: GithubRelease = await fetch(requestUrl, { | 30 | const response: GithubRelease = await fetch(requestUrl, { |
31 | headers: { Accept: "application/vnd.github.v3+json" } | 31 | headers: { Accept: "application/vnd.github.v3+json" } |
32 | }) | 32 | }) |
33 | .then(res => res.json()); | 33 | .then(res => res.json()); |
34 | 34 | ||
35 | const artifact = response.assets.find(artifact => artifact.name === artifactFileName); | 35 | const artifact = response.assets.find(artifact => artifact.name === artifactFileName); |
diff --git a/editors/code/src/installation/server.ts b/editors/code/src/installation/server.ts index 80cb719e3..63ab104a1 100644 --- a/editors/code/src/installation/server.ts +++ b/editors/code/src/installation/server.ts | |||
@@ -29,7 +29,7 @@ export async function ensureServerBinary(source: null | BinarySource): Promise<n | |||
29 | 29 | ||
30 | vscode.window.showErrorMessage( | 30 | vscode.window.showErrorMessage( |
31 | `Unable to run ${source.path} binary. ` + | 31 | `Unable to run ${source.path} binary. ` + |
32 | `To use the pre-built language server, set "rust-analyzer.raLspServerPath" ` + | 32 | `To use the pre-built language server, set "rust-analyzer.serverPath" ` + |
33 | "value to `null` or remove it from the settings to use it by default." | 33 | "value to `null` or remove it from the settings to use it by default." |
34 | ); | 34 | ); |
35 | return null; | 35 | return null; |
@@ -43,7 +43,6 @@ export async function ensureServerBinary(source: null | BinarySource): Promise<n | |||
43 | console.log("Installed version:", installedVersion, "required:", requiredVersion); | 43 | console.log("Installed version:", installedVersion, "required:", requiredVersion); |
44 | 44 | ||
45 | if (isBinaryAvailable(prebuiltBinaryPath) && installedVersion == requiredVersion) { | 45 | if (isBinaryAvailable(prebuiltBinaryPath) && installedVersion == requiredVersion) { |
46 | // FIXME: check for new releases and notify the user to update if possible | ||
47 | return prebuiltBinaryPath; | 46 | return prebuiltBinaryPath; |
48 | } | 47 | } |
49 | 48 | ||
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 0ad7ef1bb..a22e0bc66 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -11,7 +11,7 @@ import { Config } from './config'; | |||
11 | let ctx: Ctx | undefined; | 11 | let ctx: Ctx | undefined; |
12 | 12 | ||
13 | export async function activate(context: vscode.ExtensionContext) { | 13 | export async function activate(context: vscode.ExtensionContext) { |
14 | const config = new Config(context) | 14 | const config = new Config(context); |
15 | 15 | ||
16 | const serverPath = await ensureServerBinary(config.serverSource); | 16 | const serverPath = await ensureServerBinary(config.serverSource); |
17 | if (serverPath == null) { | 17 | if (serverPath == null) { |
@@ -33,7 +33,7 @@ export async function activate(context: vscode.ExtensionContext) { | |||
33 | vscode.window.showInformationMessage('Reloading rust-analyzer...'); | 33 | vscode.window.showInformationMessage('Reloading rust-analyzer...'); |
34 | // @DanTup maneuver | 34 | // @DanTup maneuver |
35 | // https://github.com/microsoft/vscode/issues/45774#issuecomment-373423895 | 35 | // https://github.com/microsoft/vscode/issues/45774#issuecomment-373423895 |
36 | await deactivate() | 36 | await deactivate(); |
37 | for (const sub of ctx.subscriptions) { | 37 | for (const sub of ctx.subscriptions) { |
38 | try { | 38 | try { |
39 | sub.dispose(); | 39 | sub.dispose(); |
@@ -41,9 +41,9 @@ export async function activate(context: vscode.ExtensionContext) { | |||
41 | console.error(e); | 41 | console.error(e); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | await activate(context) | 44 | await activate(context); |
45 | } | 45 | }; |
46 | }) | 46 | }); |
47 | 47 | ||
48 | ctx.registerCommand('analyzerStatus', commands.analyzerStatus); | 48 | ctx.registerCommand('analyzerStatus', commands.analyzerStatus); |
49 | ctx.registerCommand('collectGarbage', commands.collectGarbage); | 49 | ctx.registerCommand('collectGarbage', commands.collectGarbage); |
@@ -54,7 +54,7 @@ export async function activate(context: vscode.ExtensionContext) { | |||
54 | ctx.registerCommand('expandMacro', commands.expandMacro); | 54 | ctx.registerCommand('expandMacro', commands.expandMacro); |
55 | ctx.registerCommand('run', commands.run); | 55 | ctx.registerCommand('run', commands.run); |
56 | ctx.registerCommand('onEnter', commands.onEnter); | 56 | ctx.registerCommand('onEnter', commands.onEnter); |
57 | ctx.registerCommand('ssr', commands.ssr) | 57 | ctx.registerCommand('ssr', commands.ssr); |
58 | 58 | ||
59 | // Internal commands which are invoked by the server. | 59 | // Internal commands which are invoked by the server. |
60 | ctx.registerCommand('runSingle', commands.runSingle); | 60 | ctx.registerCommand('runSingle', commands.runSingle); |
diff --git a/editors/code/src/status_display.ts b/editors/code/src/status_display.ts index ed0d82166..0f5f6ef99 100644 --- a/editors/code/src/status_display.ts +++ b/editors/code/src/status_display.ts | |||
@@ -15,7 +15,7 @@ export function activateStatusDisplay(ctx: Ctx) { | |||
15 | WorkDoneProgress.type, | 15 | WorkDoneProgress.type, |
16 | 'rustAnalyzer/cargoWatcher', | 16 | 'rustAnalyzer/cargoWatcher', |
17 | params => statusDisplay.handleProgressNotification(params) | 17 | params => statusDisplay.handleProgressNotification(params) |
18 | )) | 18 | )); |
19 | } | 19 | } |
20 | } | 20 | } |
21 | 21 | ||