rust-analyzer
rust-analyzer copied to clipboard
Add minimal support for cargo scripts
This PR runs cargo metadata -Zscript --manifest-path=file.rs
on files opened as detached file, and then r-a will magically detect dependencies.
It doesn't touch anything in the salsa area. So, detached files need to be opened in a separate window and they are as bad as they were (no progress on #14318), and on each save operation (it needs to be on disk for cargo metadata
to work) it reads the file, checks if the //! cargo.toml
part of the script is changed, and if so it will reload the workspace and run cargo metadata
again. I think this part works good enough, but not detecting the cargo scripts inside normal projects is definitely not good.
:umbrella: The latest upstream changes (presumably #15574) made this pull request unmergeable. Please resolve the merge conflicts.
Updated the implementation building on this in a new PR https://github.com/rust-lang/rust-analyzer/pull/17110