Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Improve rust project detection #1779

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

puremourning
Copy link
Member

@puremourning puremourning commented Jan 3, 2025

Rust analyser workspaces are very heavyweight and our detection can lead to lots of them spawning. this is an attempt to rationalise that and simplify it to minimise the number of such servers.

Rust projects don't just have a single Cargo.toml. They can have a deep folder structure with multiple crates within. Cargo.lock is a better indicator of the root of the project.

Bit even then we probably want to find the furthest away Cargo.foo not the nearest, as that's more likely to be the real project root. Implement that somewhat generically so that other completers can use it. Java already has a similar codepath but it's more complicated so not touching it.

Finally, even with the above 2 changes, we still have a problem because there might jjust be gaps. Taking wasmtime project for example there are:

./Cargo.toml
./Cargo.lock
./src/foo.rs
./crates/bar/Cargo.toml
./crates/bar/src/bar.rs
./crates/baz/Cargo.toml
./crates/baz/src/baz.rs

So, we allow for the top-level 'project_directory' setting to take precedence if the file opened is in a subdirectory of it.

Fixes #1778


This change is Reviewable

Rust projects don't just have a single Cargo.toml. They can have a deep
folder structure with multiple crates within.  Cargo.lock is a better
indicator of the root of the project.

Bit even then we probably want to find the _furthest_ away Cargo.foo not
the nearest, as that's more likely to be the real project root.
Implement that somewhat generically so that other completers can use it.
Java already has a similar codepath but it's more complicated so not
touching it.

Finally, even with the above 2 changes, we still have a problem because
there might jjust be gaps. Taking wasmtime project for example there
are:

./Cargo.toml
./Cargo.lock
./src/foo.rs
./crates/bar/Cargo.toml
./crates/bar/src/bar.rs
./crates/baz/Cargo.toml
./crates/baz/src/baz.rs

So, we allow for the top-level 'project_directory' setting to take
precedence _if_ the file opened is in a subdirectory of it.
Copy link

codecov bot commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 84.21053% with 6 lines in your changes missing coverage. Please review.

Project coverage is 95.81%. Comparing base (a51329a) to head (ca8729a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1779      +/-   ##
==========================================
- Coverage   95.86%   95.81%   -0.06%     
==========================================
  Files          84       84              
  Lines        8469     8500      +31     
  Branches      163      163              
==========================================
+ Hits         8119     8144      +25     
- Misses        300      306       +6     
  Partials       50       50              

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Too many workspaces are being opened for rust-analyzer
1 participant