rust-lang / rust-lang/rust-analyzer

Getting strange preselected auto-suggestions from Rust-analyzer

Open
#14,169 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

My setup:

Arch linux
nvim 0.8.3
nvim-cmp - latest
rust-analyzer - 646f973 2023-02-12

When i code and use the autocomplete functionality, i get suggestions through vim-cmp that gets the suggestions from the source rust-analyzer. If i enable preselectMode in vim-cmp it will autoselect whatever the source thinks is best.

From the vim-cmp docs:

preselect~
  `cmp.PreselectMode`

  1. `cmp.PreselectMode.Item`
    nvim-cmp will preselect the item that the source specified.
  2. `cmp.PreselectMode.None`
    nvim-cmp will not preselect any items.

The source here is rust-analyzer as i can understand it. But what i get is very strange selections.

Here i have started to write a non-capitalized variable name, in a place clearly for variables, and i get preselected a struct with a capitalized name.
struct

Here when i do the opposite, started to write a capitalized name, i get a preselected suggestion that i want a non-capitalized variable.
bad

If i even almost spell out the entire name i want, i still get a preselected variable from rust-analyzer.
superbad

Im not really sure if the preselections come from rust-analyzer or not. Im not super well versed, in this, and dont know really how to debug this. And im also not entirely sure if it is a fault in rust-analyzer, vim-cmp, or my config/setup.

If this is the wrong place to write about this issue, i apologize, and i will close it.

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 completion behavior with Arch Linux, Neovim 0.8.3, nvim-cmp, and the reported rust-analyzer revision, using the examples and screenshots in the issue. First determine whether the preselected item is supplied by rust-analyzer or selected by nvim-cmp, then compare the completion response with the resulting UI selection. Done means the responsible component and a reproducible fix or configuration boundary are established.

Written by the indexing model from the issue text.

Assessment

Tech stack
neovim, rust
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.