rust-lang / rust-lang/rust-analyzer

Enhancement request: Priorize auto-import completions over full paths (possibly configurable?)

Open
#18,435 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi, I've looked around and couldn't find any issues that describe this exactly, so I hope this isn't a duplicate. I found some related issues (#15453, #13953 seems to basically be asking for the opposite, so maybe a configuration option makes sense).

R-a currently uses function parameter types to prioritize completions, which is great! I think this was first implemented for #15384 although the related screenshot https://github.com/rust-lang/rust-analyzer/pull/15627#issuecomment-1849605190 seems to show the behavior I am asking for, so maybe something has changed since then?

However, it provides completions with full paths (at least for enums) which can be kind of ugly for deeply nested paths; adding part of the enum name allows "standard" completion to kick in and suggest an auto-import, but it's still prioritized lower then the full paths, which can be hard to get to for enums with many members. For example:

Image
Image

Is there any way to configure r-a so that Foo (use self::contains_enum::Foo) comes first in the suggestion list? If not, could this be added as a configurable option so that folks looking for things like #13953 can retain the current behavior if they would rather use full paths?

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

No source file or test is identified in the issue. Start by examining rust-analyzer's completion prioritization and the related issues #15384, #15453, and #13953; done means auto-import completions can be ranked ahead of full-path completions, with the requested configurability clarified.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.