rust-analyzer: rust-analyzer.files.excludeDirs is (still) not working

rust-analyzer.files.excludeDirs does not appear to be working. Issue #7755 discussed this awhile ago and was closed, but the feature is still not working for me. I am using rust-analyzer 0.4.1501-standalone with rustc 1.68.2 in VSCode.

It could be that I misunderstand how to specify directories. My project layout is

.
├── src
        ├── module0

and my rust analyzer setting is

{
  "rust-analyzer.files.excludeDirs: ["src/module0"]
}

I tried also setting files.watcherExclude, as suggested in the documentation, but no luck.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 17
  • Comments: 20 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I also have this problem. It would be nice if rust-analyzer can also just use entries from the .gitignore.

Does anyone have a good workaround for this? I’m using a Nix Flake to define my development environment, and although I have added .direnv to excludeDirs rust analyzer continues to scan .direnv, and subsequently the entire nix store. It essentially never finishes.

I was actually having this issue due to using rustaceanvim plugin and it fixed itself when I switched to the rust-analyzer lsp plugin instead. Here is my config for both rustaceanvim and nvim-lspconfig.rust_analyzer using nixvim.
Enabling the rustaceanvim plugin makes it also search the .direnv folder even though it’s in the excludeDirs

This is still an issue for me, but I am currently using a simple fix which I’m posting here in case it helps somebody else.

I couldn’t get rust-analyzer to stop scanning the .direnv folder, so in the end I placed my entire crate in a subfolder one level below the flake.nix file and .direnv folder. I did this using cranes guide to placing a Cargo.toml in a non-standard location.

This has stopped the problem for me, as the .direnv folder is no longer in the workspace root. Not an ideal solution but at least something actionable.