about summary refs log tree commit diff
path: root/editors/code/src/main.ts
diff options
context:
space:
mode:
authorDavid Barsky <me@davidbarsky.com>2023-03-09 15:06:26 -0500
committerDavid Barsky <me@davidbarsky.com>2023-03-13 13:30:18 -0400
commit8af3d6367ecead0abf80e697176f697d97c25215 (patch)
tree54a28c70aadc17ddc93991fb4344a516ae6cba29 /editors/code/src/main.ts
parent95497533524537b1cc7a2870ce94b0b14503be8b (diff)
downloadrust-8af3d6367ecead0abf80e697176f697d97c25215.tar.gz
rust-8af3d6367ecead0abf80e697176f697d97c25215.zip
This commit add Cargo-style project discovery for Buck and Bazel users.
This feature requires the user to add a command that generates a
`rust-project.json` from a set of files. Project discovery can be invoked
in two ways:

1. At extension activation time, which includes the generated
   `rust-project.json` as part of the linkedProjects argument in
    InitializeParams
2. Through a new command titled "Add current file to workspace", which
   makes use of a new, rust-analyzer specific LSP request that adds
   the workspace without erasing any existing workspaces.

I think that the command-running functionality _could_ merit being
placed into its own extension (and expose it via extension contribution
points), if only provide build-system idiomatic progress reporting and
status handling, but I haven't (yet) made an extension that does this.
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r--editors/code/src/main.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 8a2412af849..323aa89ef06 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -24,11 +24,11 @@ export async function activate(
         vscode.window
             .showWarningMessage(
                 `You have both the rust-analyzer (rust-lang.rust-analyzer) and Rust (rust-lang.rust) ` +
-                    "plugins enabled. These are known to conflict and cause various functions of " +
-                    "both plugins to not work correctly. You should disable one of them.",
+                "plugins enabled. These are known to conflict and cause various functions of " +
+                "both plugins to not work correctly. You should disable one of them.",
                 "Got it"
             )
-            .then(() => {}, console.error);
+            .then(() => { }, console.error);
     }
 
     const ctx = new Ctx(context, createCommands(), fetchWorkspace());
@@ -146,13 +146,14 @@ function createCommands(): Record<string, CommandFactory> {
                     health: "stopped",
                 });
             },
-            disabled: (_) => async () => {},
+            disabled: (_) => async () => { },
         },
 
         analyzerStatus: { enabled: commands.analyzerStatus },
         memoryUsage: { enabled: commands.memoryUsage },
         shuffleCrateGraph: { enabled: commands.shuffleCrateGraph },
         reloadWorkspace: { enabled: commands.reloadWorkspace },
+        addProject: { enabled: commands.addProject },
         matchingBrace: { enabled: commands.matchingBrace },
         joinLines: { enabled: commands.joinLines },
         parentModule: { enabled: commands.parentModule },