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

support for opening a parent directory of the rust project #507

Open samuela opened 5 years ago

samuela commented 5 years ago

I have a project laid out as a monorepo, something like:

my-project/
  api/
  web/
  rust-project/

Now rls-vscode works great if I open up vscode at my-project/rust-project/ but it doesn't work at all if I open up the root folder my-project/ as I prefer to do:

could not find 'Cargo.toml' in 'my-project/' or any parent directory

It would be nice to support project lookup relative to the file actually being edited as opposed to just assuming that the whole folder is a rust project. Because monorepos, blah blah blah.

samuela commented 5 years ago

This bit looks like the culprit: https://github.com/rust-lang/rls-vscode/blob/f23a1d54c47b2f9e7595bca8c66f30d4abeba357/src/extension.ts#L60

lokmeinmatz commented 5 years ago

Having the same issue, kind of annoying :(

supernomad commented 5 years ago

yea just ran into this as well, can work around it but this particular issue does make working with mono-repo style projects less than ideal.

MonsieurMan commented 5 years ago

A pull request solving this issue is open here #638 !

samuela commented 4 years ago

FWIW this works out of the box with rust-analyzer.

abrykajlo commented 4 years ago

@samuela I am not sure it does, I am currently running on Windows with Rust-client Engine set to rust-analyzer in my user settings and it only works for me when my root directory is the rust project folder

abrykajlo commented 4 years ago

Further testing it looks to only go one parent folder deep. My folder structure looks more like this:

my-project/
    backend/
    webpack-frontend/
        wasm-crate/

when in my-project wasm-crate does not get completion. Although I guess quick fix would be to rearrange like this:

my-project/
    backend/
    wasm-crate/
    webpack-frontend/

then just use a relative path from webpack-frontend to wasm-crate.

Sorry I am just doing stream of conscious, if someone else comes across my same case could be useful.