rust-lang / rls

Repository for the Rust Language Server (aka RLS)
Other
3.51k stars 257 forks source link

Code completion for `use` #559

Open nrc opened 6 years ago

nrc commented 6 years ago

It occurs to me that we could have very quick, perfect code completion for use without using the compiler. If we knew we were in a use expression, then we could use the tree of defs to suggest possible imports. We'd have to be a bit clever to handle self and super, but otherwise this should be fairly straightforward and fast because we wouldn't need to go to the compiler.

nrc commented 6 years ago

@johshoff hey, did you look into this? Did you get far? Anything I can do to help?

johshoff commented 6 years ago

Hi, @nrc ! Unfortunately I didn't get very far on this; so far I've only read code. I will be pretty busy going forward, so I wouldn't be upset if anyone else grabs this. If not, though, I will work on this for the second installment of Portland's impl party.

I do have a question, though: It looks like completions are done exclusively by racer. What's the plan for that going forward? Move piece by piece over to rls-analysis?

nrc commented 6 years ago

I do have a question, though: It looks like completions are done exclusively by racer. What's the plan for that going forward? Move piece by piece over to rls-analysis?

There might be other bits and pieces that we can do in the RLS (like the use thing here), but I don't know any off the top of my head. The grand plan is that we out-source all code completion to the compiler, but that requires a fair bit of work in the compiler to achieve, not least evolving incremental compilation to the point that we can get 'instant' results for a code completion query.