diff options
| author | David Barsky <me@davidbarsky.com> | 2023-11-07 16:26:32 -0500 |
|---|---|---|
| committer | David Barsky <me@davidbarsky.com> | 2024-02-08 14:23:00 -0500 |
| commit | 6330b028b3f4d10220170fa995aeeb0655f9e8dc (patch) | |
| tree | ad3606ed7fb4ba79c1df7d1f9ad70bb7b3774fcf /editors/code/src | |
| parent | ca44e1ee9f993d9e7a4fbb83eea3f28aaf0f0306 (diff) | |
feature: Add a `UnindexedProject` notification and a corresponding setting.
Diffstat (limited to 'editors/code/src')
| -rw-r--r-- | editors/code/src/ctx.ts | 17 | ||||
| -rw-r--r-- | editors/code/src/lsp_ext.ts | 6 |
2 files changed, 23 insertions, 0 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 55163241c2a..01a3aca1323 100644 --- a/editors/code/src/ctx.ts +++ b/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/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index f959a76639e..6c961f53e7e 100644 --- a/editors/code/src/lsp_ext.ts +++ b/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[] }; |
