about summary refs log tree commit diff
path: root/editors/code/src
diff options
context:
space:
mode:
authorDavid Barsky <me@davidbarsky.com>2023-11-07 16:26:32 -0500
committerDavid Barsky <me@davidbarsky.com>2024-02-08 14:23:00 -0500
commit6330b028b3f4d10220170fa995aeeb0655f9e8dc (patch)
treead3606ed7fb4ba79c1df7d1f9ad70bb7b3774fcf /editors/code/src
parentca44e1ee9f993d9e7a4fbb83eea3f28aaf0f0306 (diff)
feature: Add a `UnindexedProject` notification and a corresponding setting.
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/ctx.ts17
-rw-r--r--editors/code/src/lsp_ext.ts6
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[] };