rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Allow us to put fields before trait methods in autocompletion

Open guyguy2001 opened this issue 1 year ago • 1 comments

I'm using rust-analyzer in a bevy game project. Most of my structs derive from Reflect, which adds a lot of trait-methods that spam the autocompletion for me, and hide the actually relevant fields: image image

I never use the Reflect methods in my own code, I only derive from it so that Bevy (and other core packages) can benefit from it.

IDK how common it for general rust projects to encounter this issue, but from what I've seen it will always happen when working with bevy.

I see 2 solutions for this:

  • Make fields appear at the start of the list, alongside methods defined on the object itself, instead of alongside trait methods.
  • Allow us to hide methods of a specific trait from the list, or move them to the end. I could see a world in which some first-class methods are defined in a trait, and you would also not want these methods to get hidden behind all of the unimportant Reflect methods.

(keywords: order)

guyguy2001 avatar Aug 10 '24 12:08 guyguy2001

I think the first solution you outlined provides substantial utility to the whole Rust ecosystem. For most code bases I work in, fields and inherent methods probably represent the majority of what I access by a fair amount.

CorvusPrudens avatar Aug 22 '24 18:08 CorvusPrudens