diff options
| author | Laurențiu Nicola <lnicola@dend.ro> | 2024-02-11 08:40:19 +0200 |
|---|---|---|
| committer | Laurențiu Nicola <lnicola@dend.ro> | 2024-02-11 08:40:19 +0200 |
| commit | 022af828278f568cc2a92c845836d2632d7a69e5 (patch) | |
| tree | 1e607db1219ad4563ed379cb3eec6bf138ee03e6 /src/tools/rust-analyzer/editors/code | |
| parent | 9aa232ecc7bb006a1fad404f437b049482021a3a (diff) | |
| parent | ddf105b646c6749a2de2451c9a499a354eec79c2 (diff) | |
Merge commit 'ddf105b646c6749a2de2451c9a499a354eec79c2' into sync-from-ra
Diffstat (limited to 'src/tools/rust-analyzer/editors/code')
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/package.json | 10 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/src/ctx.ts | 17 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/src/lsp_ext.ts | 6 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/src/main.ts | 2 |
4 files changed, 34 insertions, 1 deletions
diff --git a/src/tools/rust-analyzer/editors/code/package.json b/src/tools/rust-analyzer/editors/code/package.json index 841e364ed84..b474471e5a4 100644 --- a/src/tools/rust-analyzer/editors/code/package.json +++ b/src/tools/rust-analyzer/editors/code/package.json @@ -803,6 +803,11 @@ } ] }, + "rust-analyzer.check.workspace": { + "markdownDescription": "Whether `--workspace` should be passed to `cargo check`.\nIf false, `-p <package>` will be passed instead.", + "default": true, + "type": "boolean" + }, "rust-analyzer.completion.autoimport.enable": { "markdownDescription": "Toggles the additional completions that automatically add imports when completed.\nNote that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.", "default": true, @@ -1468,6 +1473,11 @@ "default": true, "type": "boolean" }, + "rust-analyzer.notifications.unindexedProject": { + "markdownDescription": "Whether to send an UnindexedProject notification to the client.", + "default": false, + "type": "boolean" + }, "rust-analyzer.numThreads": { "markdownDescription": "How many worker threads in the main loop. The default `null` means to pick automatically.", "default": null, diff --git a/src/tools/rust-analyzer/editors/code/src/ctx.ts b/src/tools/rust-analyzer/editors/code/src/ctx.ts index 55163241c2a..01a3aca1323 100644 --- a/src/tools/rust-analyzer/editors/code/src/ctx.ts +++ b/src/tools/rust-analyzer/editors/code/src/ctx.ts @@ -234,6 +234,23 @@ export class Ctx implements RustAnalyzerExtensionApi { this.outputChannel!.show(); }), ); + this.pushClientCleanup( + this._client.onNotification(ra.unindexedProject, async (params) => { + if (this.config.discoverProjectRunner) { + const command = `${this.config.discoverProjectRunner}.discoverWorkspaceCommand`; + log.info(`running command: ${command}`); + const uris = params.textDocuments.map((doc) => + vscode.Uri.parse(doc.uri, true), + ); + const projects: JsonProject[] = await vscode.commands.executeCommand( + command, + uris, + ); + this.setWorkspaces(projects); + await this.notifyRustAnalyzer(); + } + }), + ); } return this._client; } diff --git a/src/tools/rust-analyzer/editors/code/src/lsp_ext.ts b/src/tools/rust-analyzer/editors/code/src/lsp_ext.ts index f959a76639e..6c961f53e7e 100644 --- a/src/tools/rust-analyzer/editors/code/src/lsp_ext.ts +++ b/src/tools/rust-analyzer/editors/code/src/lsp_ext.ts @@ -220,3 +220,9 @@ export type RecursiveMemoryLayoutNode = { export type RecursiveMemoryLayout = { nodes: RecursiveMemoryLayoutNode[]; }; + +export const unindexedProject = new lc.NotificationType<UnindexedProjectParams>( + "rust-analyzer/unindexedProject", +); + +export type UnindexedProjectParams = { textDocuments: lc.TextDocumentIdentifier[] }; diff --git a/src/tools/rust-analyzer/editors/code/src/main.ts b/src/tools/rust-analyzer/editors/code/src/main.ts index c386b9e5d8f..0af58fd7812 100644 --- a/src/tools/rust-analyzer/editors/code/src/main.ts +++ b/src/tools/rust-analyzer/editors/code/src/main.ts @@ -207,7 +207,7 @@ function checkConflictingExtensions() { if (vscode.extensions.getExtension("panicbit.cargo")) { vscode.window .showWarningMessage( - `You have both the rust-analyzer (rust-lang.rust-analyzer) and Cargo (panicbit.cargo) plugins enabled` + + `You have both the rust-analyzer (rust-lang.rust-analyzer) and Cargo (panicbit.cargo) plugins enabled, ` + 'you can disable it or set {"cargo.automaticCheck": false} in settings.json to avoid invoking cargo twice', "Got it", ) |
