rust-lang / rust-lang/rust-analyzer

Add support for "Create Module" as a directory instead of a file

Open
#4,241 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics E-hard S-unactionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Right now, I can use the awesome "Create Module" on the lightbulb menu to create a module from just the mod xyz; statement. However, this always creates it as a file and not as a directory.

It would be really useful if it were able to do both - probably as separate menu items - for the cases where you actually do want to create a directory for the module instead of just a single file.

Reproduction

  • Write mod xyz;
  • Click Lightbulb
  • Click "create module"

Current Behaviour

  • A new file "xyz.rs" will be created adjacent to this file

Desired Behaviour

  • A new directory "xyz" will be created adjacent to this file
  • A new file "mod.rs" will be created inside this new directory

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue from a mod xyz; statement through the Lightbulb menu's "Create Module" action. Trace that action's entry point and verify how it chooses the generated path. Done means the existing file behavior remains available and a directory xyz containing mod.rs can be created adjacent to the source file.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.