rust-lang / vscode-rust

Rust extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=rust-lang.rust
Other
1.39k stars 167 forks source link

intellisense doesnt work for member functions or properties of types defined in crates. #386

Closed haggerty-william closed 5 years ago

haggerty-william commented 6 years ago

So I am a beginner with rust and I am trying to follow the pong tutorial for the amethyst game engine using vscode as my ide. At first I thought that there was no working intellisense at all but after a while I realized that it just didnt work on anything from any of the crates i use as a dependency. For example if I do: use amethyst::renderer::DisplayConfig; let path = "./resources/display_config.ron"; let input_bundle = InputBundle::<String, String>::new().with_bindings_from_file(binding_path);

I can see all functions available on the string object path , but If I create the InputBundle object from amethest, I cannot see any of the functions available to execute off of that object.

Is this too be expected? Is there any way to get intellisense to work with external dependencies?

haggerty-william commented 6 years ago

I should point out that I am on ubuntu 16.04 LTS and I am using Version: 1.25.1 of vscode and 0.4.9 of Rust(rls) using rls-preview 0.127.0-stable (d2ade31 2018-05-08).

nrc commented 6 years ago

aiui this should work as long as the source for the dependent crates which Cargo downloads is in the usual place.

cc @kngwyu - would you expect this to work? If so, any idea what is going wrong?

kngwyu commented 6 years ago

It's intended to work, but now I don't have enough time to debug...

kngwyu commented 6 years ago

image Can't reproduce with racer 2.1.3

haggerty-william commented 6 years ago

Well, I updated racer to 2.1.3 and it still isn't working like you have it working above. More version info after some updates:

racer 2.1.3 cargo 1.27.0 (1e95190e5 2018-05-27) rustc 1.27.2 (58cc626de 2018-07-18) rls-preview 0.127.0-stable (d2ade31 2018-05-08)

code --version 1.25.1 1dfc5e557209371715f655691b1235b6b26a06be x64

If there is anything that I am missing that could help diagnose the issue let me know, I am new to rust development.

kngwyu commented 6 years ago

@haggerty-william How about updating rls?

haggerty-william commented 6 years ago

rustup and the vscode 'Update rls' command says it is up to date.

nrc commented 6 years ago

we'll need to update the RLS in the Rust repo before rustup can update. That should happen around the end of the week. In the mean time you could build from source if you want to try it out.

haggerty-william commented 6 years ago

updated to: rls-preview 0.128.0-stable (7d0bc55 2018-06-07) cargo 1.28.0 (96a2c7d16 2018-07-13) racer 2.1.3 rustc 1.28.0 (9634041f0 2018-07-30)

VSCode: 1.25.1 1dfc5e557209371715f655691b1235b6b26a06be x64

No change in behavior.

cynecx commented 6 years ago

Using an updated toolchain won‘t help right now because it still includes an old version of rls as you can clearly see.

Clone this repository and build it from source (nrc has mentioned this before), then configure vscode to use the freshly built rls executable.

haggerty-william commented 6 years ago

I cannot clearly see that. What I see was an update from rls-preview 0.127.0 to rls-preview 0.128.0. Is rls-preview 0.128.0 an old version of rls even though it was published within 24 hours or so?

cynecx commented 6 years ago

rls-preview 0.128.0-stable (7d0bc55 2018-06-07)

https://github.com/rust-lang-nursery/rls/commit/7d0bc55

An updated toolchain (rustup update) does not exactly imply that all components has been updated.

kngwyu commented 6 years ago

To get the latest rls you have to type

rustup toolchain add nightly
rustup component add --toolchain nightly rls-preview

Maybe you need the version newer than 2018-07-23 not to see this bug, sorry.

haggerty-william commented 6 years ago

Tried this on 16.04, then did a new install on 18.04 ubuntu, no use. I'm going to put learning rust aside for now, I am not used to programming without these features and it doesn't seem like anything i can do will make it work. Thanks for your help.

DanielJoyce commented 6 years ago

@haggerty-william You might try rls on atom. It doesn't seem to break as often. Rls support in vscode seems to break all the time and is unstable. I will have a working install for a month, run an update, and some features will break, only to start working in another update.

There really needs to be a way to test this stuff before release. It really does provide a bad experience for getting into rust.

haggerty-william commented 6 years ago

@DanielJoyce I tried it with IntelliJ IDEA shortly after saying I was done and it didn't work there either, maybe it would work with atom but I don't really care anymore. I'll probably come back in a while and try to get things to work.

jonathansty commented 6 years ago

I find RLS in vscode completely unusable usually. I'm using the nightly:

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.30.0-nightly (fc81e3624 2018-09-07)

When for example using the glfw crate intelisense seems to work for types I have explicetely declared but not when I do things like:

let (mut window, event_receiver) = glfw.create_window(512, 512, "framework", glfw::WindowMode::Windowed).expect("Failed to create a window!");

When I then try to use "window" it won't show me anything useful I could use. I then try to navigate to the symbols for that crate and that's also not really possible looking for "create_window" as a symbol yields no results...

Elementals commented 6 years ago

To all the developers of this extension: have you evaluated the influence of the difference between "LF/CRLF" line endings? [On Windows] Using "LF" ending with nightly rust, everything runs flawlessly, otherwise not. When I change to "CRLF", rls builds again, but this won't help, code completion just works properly in "LF" (@kngwyu Racer's bug?).

Also, Racer require nightly rust, why you haven't mention this in the VSCode page? (And this causes huge difference indeed, never get code completion work in stable rust.)

@haggerty-william Linux use LF but I don't know if Amethyst generates new projects using CRLF by default. You can try workaround above when you have time.

DanielJoyce commented 6 years ago

@Elementals Will try this out later. The whole RLS situation seems a bit more stable under atom. This whole experience has kinda soured me. Great language but tooling is still borked several years on. And 2017 was supposed to be the year of productivity..

Xanewok commented 5 years ago

This should work now and the fix for LF/CRLF has been merged in Racer some time ago. Closing this now but please reopen if the issue still persists!