Is it possible for Rust-Analyzer to understand what files have changed since the last session by interacting with git and parse the modified files/crates only?
I'm asking about it because, currently, Rust-Analyzer tries to parse the entire codebase everytime I open a project and it makes my computer slow.
If this were implemented, it would cause compilation to become quite brittle. Consider, what would happen if someone did a cargo clean right after pushing all their changes?
According to git, nothing has changed, so using that heuristic, nothing would need to be compiled. But all the compilation artifacts are gone due to the cargo clean, so in actuality the entire project should be recompiled.
I don't mean to be facetious, but this most likely either means you have some other processes that need to be killed when you compile code, or you need a faster machine. Optimizing the Rust compilation pipeline in a meaningful way is notoriously hard.
Rust-analyzer doesn't cache anything on the disk. It is architectured to lazily process code as necessary. By default cache priming is enabled though which fills many caches eagerly to make future commands faster. (can be disabled using rust-analyzer.cachePriming.enable) This cache priming does not block any ide interaction, so if ide interaction is slow during startup that is because rust-analyzer genuinely needs the thing it is currently working on to be computed.
I wonder what people are thinking when they entirely skip steps. Asking questions like βcan this car fly to San-Diego?β without ever bothering to ask if that's a flying car at all.
You don't need git for that, do you? Persistent caches is what you need. There's an issue for that.
That would be an interesting next step, maybe. Very much unlikely, given the fact that even persistent caches in general are not implemented yet.