Open jkelleyrtp opened 3 months ago
Hm, I would not be too fond of adding such an index to rust-analyzer as we'd need to occasionally keep it up to date and its usefulness varies from codebase to codebase. We should be doing something here though for sure.
The scoring is a little weird though.
It is, no one ever really looked into it with a bigger picture in mind. Its just a bunch of rules that were incrementally added so they don't necessarily make sense in terms of their scoring weights by now.
Hm, I would not be too fond of adding such an index to rust-analyzer as we'd need to occasionally keep it up to date and its usefulness varies from codebase to codebase. We should be doing something here though for sure.
The scoring is a little weird though.
It is, no one ever really looked into it with a bigger picture in mind. Its just a bunch of rules that were incrementally added so they don't necessarily make sense in terms of their scoring weights by now.
I'd imagine we wouldn't need to update the index that frequently and it'd be simpler to do an upfront index creation than it would be to automate it based on the codebase. That being said, we could also do it on the codebase when the codebase is launched, but then it'd be less helpful on fresh codebases. The better solution long term would be to create a base index that's refined by the project in question - ie some sort of "temperature" metric influenced by the codebase you're in.
I'd be happy to take a stab at doing a token analysis of a number of popular rust projects and then implementing the temperature tweak.
I would really keep it simpler for now. Maybe even just special case clone or have some user configurable list of shortcut mappings or something like that
I have the very same issue. clamp() as the first suggestion instead of clone() is annoying. There is a simple solution: for example, RustRover has option to exclude specific items from suggestion list: https://www.jetbrains.com/help/rust/rust-autocomplete-code.html#disable-auto-import
So, in our example, we could just manually exclude trait Ord in rust-analyzer settings.
Suggestion list shows trait source for every method, so it already has information required for filtering. This feature should be simple to implement.
UPDATE. In settings, I've set "Editor: Suggest Selection" to "recentlyUsedByPrefix" ("Controls how suggestions are pre-selected when showing the suggest list"). It provides better experience already. In our example, when I type "variable.", it pre-selects "clone()".
I frequently use autocomplete on methods/functions. The scoring is a little weird though.
99% of the time I want
cl
to complete toclone
but it completes toclamp
. I get why, but this gets annoying.I'd be happy to implement a scoring system that suggest relevant tokens instead of alphabetically.
I was thinking of scraping the top rust projects, doing a frequency analysis of tokens, and then baking that into a scoring hashmap which RA can use to provide nicer suggestions.