Skip to content

Commit 28f842e

Browse files
committed
Add VS Code new project command
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, 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.
1 parent adef948 commit 28f842e

7 files changed

Lines changed: 564 additions & 4 deletions

File tree

editors/code/package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@
214214
"title": "Reload workspace",
215215
"category": "rust-analyzer"
216216
},
217+
{
218+
"command": "rust-analyzer.newProject",
219+
"title": "Create New Project...",
220+
"category": "rust-analyzer"
221+
},
217222
{
218223
"command": "rust-analyzer.rebuildProcMacros",
219224
"title": "Rebuild proc macros and build scripts",
@@ -486,6 +491,23 @@
486491
"markdownDescription": "Do not start rust-analyzer server when the extension is activated.",
487492
"default": false,
488493
"type": "boolean"
494+
},
495+
"rust-analyzer.projectCreation.openAfterCreate": {
496+
"markdownDescription": "Control what happens after `rust-analyzer: Create New Project...` finishes creating a Cargo project.",
497+
"default": "ask",
498+
"enum": [
499+
"ask",
500+
"open",
501+
"openNewWindow",
502+
"addToWorkspace"
503+
],
504+
"enumDescriptions": [
505+
"Prompt for how to open the new project.",
506+
"Open the new project in the current window.",
507+
"Open the new project in a new window.",
508+
"Add the new project to the current workspace, or open it if no workspace is open."
509+
],
510+
"type": "string"
489511
}
490512
}
491513
},
@@ -3794,6 +3816,9 @@
37943816
"command": "rust-analyzer.memoryUsage",
37953817
"when": "inRustProject"
37963818
},
3819+
{
3820+
"command": "rust-analyzer.newProject"
3821+
},
37973822
{
37983823
"command": "rust-analyzer.reloadWorkspace",
37993824
"when": "inRustProject"
@@ -3909,6 +3934,13 @@
39093934
}
39103935
]
39113936
},
3937+
"viewsWelcome": [
3938+
{
3939+
"view": "explorer",
3940+
"contents": "Create a new Rust project.\n[Create Rust Project](command:rust-analyzer.newProject)",
3941+
"when": "workspaceFolderCount == 0"
3942+
}
3943+
],
39123944
"viewsContainers": {
39133945
"activitybar": [
39143946
{
@@ -3934,6 +3966,14 @@
39343966
"title": "Learn about rust-analyzer",
39353967
"description": "A brief introduction to get started with rust-analyzer. Learn about key features and resources to help you get the most out of the extension.",
39363968
"steps": [
3969+
{
3970+
"id": "create-project",
3971+
"title": "Create a Rust project",
3972+
"description": "Start a new Cargo binary or library project from VS Code.\n\n[Create a Rust Project](command:rust-analyzer.newProject)",
3973+
"media": {
3974+
"markdown": "./walkthrough-create-project.md"
3975+
}
3976+
},
39373977
{
39383978
"id": "setup",
39393979
"title": "Useful Setup Tips",

0 commit comments

Comments
 (0)