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

Why load all folders in workspace #11588

Open
tjx666 opened this issue Feb 28, 2022 · 9 comments
Open

Why load all folders in workspace #11588

tjx666 opened this issue Feb 28, 2022 · 9 comments
Labels
C-support Category: support questions S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@tjx666
Copy link

tjx666 commented Feb 28, 2022

In following workspace, there are may folders. Each folder is a crate.
When I open this workspace, rust-analyzer will load all folders which heavily increae the timeout to get seamatic highlight and intellisence.

image

Why not just load the folder which user had open rust file in it?

For example, when I open the main.rs in folder enums, just load the metadata of this crate.

My workspace settings:

image

@tjx666 tjx666 changed the title Why load all folder in workspace Why load alls folder in workspace Feb 28, 2022
@bjorn3
Copy link
Member

bjorn3 commented Feb 28, 2022

You can set "rust-analyzer.cache.warmup": false to disable warming up of cache at startup.

@tjx666 tjx666 changed the title Why load alls folder in workspace Why load all folders in workspace Mar 1, 2022
@tjx666
Copy link
Author

tjx666 commented Mar 1, 2022

@bjorn3 I tried it, but useless.

image

@bjorn3
Copy link
Member

bjorn3 commented Mar 1, 2022

That is running the build scripts of all crates to get generated source files and compiling all proc macros. The results of this are cached by cargo, so you should only have to pay for it once if you don't change any build scripts or proc macros even if you restart rust-analyzer. If you want to disable this you can use set rust-analyzer.cargo.runBuildScripts and rust-analyzer.procMacro.enable to false. This may break things if dependencies of you depend on them though.

https://github.com/rust-analyzer/rust-analyzer/blob/cbbb7f351f1b6297f0da91ea12d323051e71380c/crates/project_model/src/build_scripts.rs#L153

@tjx666
Copy link
Author

tjx666 commented Mar 1, 2022

When I restart rust-analyzer, it will still load all crates again even if I didn't change anything. All the crates in my workspace doesn't depend each other. Why not rust-analyze analyzes the dependency relationship and load only the open folder and it's dependecies.

@flodiebold flodiebold added S-unactionable Issue requires feedback, design decisions or is blocked on other work C-support Category: support questions labels Mar 4, 2022
@calops
Copy link

calops commented Jan 6, 2023

I do wish there was an option to disable indexing everything whenever I open a crate within a workspace. Right now, the only workaround I've found is to temporarily comment the workspace line in the crate's Cargo.toml, otherwise indexing time and memory usage are simply unbearable. But it's tedious to do it every time I switch projects.

@lnicola
Copy link
Member

lnicola commented Jan 6, 2023

@calops have you tried disabling rust-analyzer.cachePriming.enable?

@calops
Copy link

calops commented Jan 6, 2023

It is better with that setting (thanks for that), however it still builds all the proc macros of the other crates, and still cargo check everything by default (although I can override that command, I feel like there should be a less hacky solution for this).

It also seems to not index the dependencies of my crate when I do this? If that's right, it's still not a suitable solution for me.

@zjp-CN
Copy link

zjp-CN commented Apr 23, 2024

It is better with that setting (thanks for that), however it still builds all the proc macros of the other crates, and still cargo check everything by default (although I can override that command, I feel like there should be a less hacky solution for this).

IIUC Your requirement seems not related to the issue. You want cargo-check without --workspace, then just set check.workspace to false since #16510 .

@calops
Copy link

calops commented Apr 24, 2024

Yeah that's fair, this new option solves my use-case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-support Category: support questions S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

No branches or pull requests

6 participants