lapce / lapce-plugin-rust

Apache License 2.0
31 stars 9 forks source link

Option to use alternate build directory for rust-analyzer #24

Open timboudreau opened 3 months ago

timboudreau commented 3 months ago

I have a workspace with ~30 crates in it; cargo check can sometimes take quite a while. So, doing an edit and then attempting to build in a shell often means the build is blocked waiting on cargo check to release the lock on the build directory.

A simple solution would be to have the check use a different build directory, so local builds and whatever the Rust plugin wants to do simply can't collide.

It appears that is doable, with some caveats:

Despite that, it looks as if it might work to simply point the analyzer at, say, /tmp/$WORKSPACE_PATH_HASH (some short name derived from the workspace path to avoid collisions) or something like that.

Or it might be possible to simply ensure that, while cargo check uses the configuration of the debug profile (or whatever) it doesn't use $TARGET/debug for whatever it wants to write.

Could be implemented as an enablable option to use a $TMP subdir and just ensure the subdir exists before calling it; or as an option to pass arguments or env vars when calling cargo check - although that might be problematic, since if someone did that, every Rust project would try to use the same directory (unless you want to implement some sort of variable dereferencing in the settings).

Anyway, it appears solvable, and would make a big difference in productivity for anyone who winds up waiting several minutes for cargo check for their build/test/whatever to run.

panekj commented 3 months ago

You can use custom command directly in rust-analyzer, no need to implement anything here