rust-lang / rust-lang/rust-analyzer

feature request: Insert qualified path (auto-imports)

Open
#13,953 11 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-completion C-feature S-actionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

I can either:

  • Enable auto-imports
    • Have sugestions for non-imported items
    • Completion for these items insert a use statement on top of the file
  • Disable auto-imports
    • Not have sugestions for non-imported items at all.

Considering that rust analyzer already have quick-fix to Replace qualified path with use, I don't see a point of always inserting use statement on completion. I want third option:

  • Insert qualified path
    • Have sugestions for non-imported items
    • Completion for these items insert qualified path

(when i type fs, I should still see an option for std::fs, but pressing tab should insert std::fs, not use std::fs; on top of the file).

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

Start by tracing rust-analyzer's completion handling for non-imported items and the existing “Replace qualified path with use” quick-fix. Compare the three requested auto-import modes, then verify that selecting a non-imported item in the new mode inserts its qualified path while preserving the existing behaviors.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.