Add VS Code create new project command#22103
Conversation
d7ff960 to
28f842e
Compare
|
This is a large wall of code, and I'm not even sure this feature is in scope for r-a. |
It's working, self-reviewed, tested manually and with unit tests, with a firm spec in the linked issue that I spent time iterating on prior to throwing the tooling at it, plus refactoring and improving the generated code. It exists because other extensions do this already, and it allows me to live in vscode rather than a terminal in order to create rust applications / libraries. This seems like a solidly good way to validate whether it's scope. r-a is the place where rust projects live in vscode. From that perspective creating a new rust project in vscode should live in r-a. |
|
As a general question, which other extensions do this? I don't have any extensions installed with a similar feature, except for the Typst one. Though I don't fully understand the Typst one. I think Typst does it, because it doesn't rely on a CLI? |
(From the issue plan details) #19338 (comment): |
f8c20bf to
1cb93f3
Compare
70f7933 to
762b4e9
Compare
|
I pushed a cleanup pass aimed at making this easier to review: the new-project workflow now lives in Scope-wise, this still delegates project creation to |
762b4e9 to
585332d
Compare
This comment has been minimized.
This comment has been minimized.
585332d to
8ec8486
Compare
Screen.Recording.2026-05-06.at.00.28.18.mov |
|
ping |
Implement a rust-analyzer VS Code command for creating new Cargo projects from the editor. Add command registration, UI entry points, configuration for post-create behavior, focused validation, and tests for the command flow. AI tools were used to research comparable editor behaviors and help refine the implementation plan; the resulting changes were reviewed before submission.
8ec8486 to
3376c4b
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
ping |
|
(unsure if you're the best person to review this #t-compiler/rust-analyzer > New project command in VSCode @ 💬) |
Point the new project failure flow at the extension logs and make the log-opening command available when the language server is not running. Also add tests for the env-aware cargo path resolution path introduced for project creation.
|
Formatting failures |
Run the VS Code formatter to fix the remaining Prettier issue in the launch config test before updating PR rust-lang#22103. AI-assisted: OpenAI Codex was used to identify and apply this change.
This comment has been minimized.
This comment has been minimized.
Run the VS Code formatter to fix the remaining Prettier issue in the launch config test before updating rust-lang#22103. AI-assisted: OpenAI Codex was used to identify and apply this change.
be0c3f2 to
4af6a26
Compare
Run the VS Code formatter to fix the remaining Prettier issue in the launch config test before updating rust-lang#22103. AI-assisted: OpenAI Codex was used to identify and apply this change.
9c34714 to
c0a10a8
Compare
|
Iterating on the windows CI failure (I'm not actively testing on windows generally. Leaving that to CI here. |
c0a10a8 to
0ab0e38
Compare
Handle Windows executable suffixes when the VS Code extension probes for cargo through PATH or CARGO_HOME, and preserve case-insensitive environment variable lookup for supplied env objects so copied Windows `Path` entries still resolve cargo. Normalize and document the Windows CARGO_HOME test comparison as well, because VS Code path resolution can lowercase the drive letter in `fsPath` without changing which executable was found. This keeps the extension-side lookup aligned with the Rust-side toolchain helper behavior and avoids breaking create-project on common Windows setups. AI-assisted: OpenAI Codex was used to identify and apply this change.
0ab0e38 to
c690a64
Compare
|
The Windows CI failures on this PR turned up three separate issues in the VS Code-side cargo/toolchain resolution changes:
|
|
@rustbot ready |
|
@Veykril can this be merged? |
|
Thanks! |
Run the VS Code formatter to fix the remaining Prettier issue in the launch config test before updating rust-lang/rust-analyzer#22103. AI-assisted: OpenAI Codex was used to identify and apply this change.








Fixes #19338.
Summary
Add a VS Code command for creating a new Rust project from the editor.
The command prompts for a project kind, parent folder, and package name, then runs
cargo newwith the same effective environment used by the extension. After creation, it can open the project, open it in a new window, or add it to the current VS Code workspace.Details
rust-analyzer.newProjectcommand.rust-analyzer.projectCreation.openAfterCreateto configure the post-create action.~shortening for now. That can be re-added later if wanted.Testing
npm -C editors/code run typechecknpm -C editors/code testnpm exec -- prettier src/new_project.ts tests/unit/commands.test.ts --checknpm exec -- eslint src/new_project.ts tests/unit/commands.test.tsAI disclosure
I used Codex/AI tooling to research similar editor implementations, refine the implementation plan, review parts of the code structure, and draft/refine portions of this change. I reviewed the resulting code and notes before opening this PR.