rust-lang / rust-lang/rust-analyzer
Feature: Action to explicitly import a path
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I often want to add use statements before writing the code that uses them, either because I need autocomplete to actually be definitive or because I'm trying to add a glob import (especially a crate::prelude::* import). I really wish Rust Analyzer had an explicit action that let me provide a path that it would import. The primary benefit here is having it keep my imports organized according to my configured auto-import settings. This is especially useful when I'm trying to add an import for which a group doesn't exist yet and I can't remember the correct ordering of import groups.
Bonus points if this same feature can also tell me what other paths I've already imported whose prefix matches what I'm typing. That way I could trigger this action and use it to check what I've already imported from a given crate/module without having to scroll to the top and back down.
This feature could also help with the problem of adding imports at scopes other than module scope, as there could be variants on the action for importing at function scope or innermost block scope (also see #8103).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the requested explicit import action and the related scope issue #8103. Define the smallest complete version around supplying a path and applying the configured import organization; consider the existing-import lookup and function or block scope variants separately. Done should include a clear action contract and tests for the supported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100