rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

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

Open willtunnels opened this issue 2 years ago • 15 comments

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.

willtunnels avatar May 04 '23 12:05 willtunnels

same here. I have a tests/ directory with a lot of small, non-rust files, that stops rust-analyzer from being able to resolve symbols (no idea why). If I move the directory out of the way, RA works. But no form of excludeDirs I've found has any effect.

I'm using vim-lsp, e.g.

if executable('rust-analyzer')
  au User lsp_setup call lsp#register_server({
        \   'name': 'Rust Language Server',
        \   'cmd': {server_info->['rust-analyzer']},
        \ 'root_uri':{server_info->lsp#utils#get_default_root_uri()},
        \ 'initialization_options': { "rust-analyzer.files.excludeDirs": [ "tests", "vendor" ] },
        \   'whitelist': ['rust'],
        \ })
endif

with no effect.

jlevon avatar May 05 '23 23:05 jlevon

I have the same issue with non-rust files I use rust syntax highlighting for. They aren't in src/ and don't initially get checked but as soon as I open one in the editor rust-analyzer generates lot's of syntax errors. excludeDirs does not seem to have any effect at all.

sinesc avatar Aug 07 '23 18:08 sinesc

I am having the same issue.

cloutiertyler avatar Sep 30 '23 05:09 cloutiertyler

This sort of works for me:

if executable('rust-analyzer')
  au User lsp_setup call lsp#register_server({
        \   'name': 'Rust Language Server',
        \   'cmd': {server_info->['rust-analyzer']},
        \   'whitelist': ['rust'],
        \   'initialization_options': {
        \        'files': {
        \            'excludeDirs': ['tests', 'vendor'],
        \        }
        \   }
        \ })
endif
$ rust-analyzer --version
rust-analyzer 1.72.1 (d5c2e9c 2023-09-13)

This does seem to ignore tests/ dir (which happens to basically completely break rust-analyzer, and has no rust sources in it), but rust-analyzer still looks at vendor - presumably because it's referenced from src/

jlevon avatar Sep 30 '23 10:09 jlevon

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

Andrew15-5 avatar Jan 28 '24 20:01 Andrew15-5

I'm having the same problem. It would be nice if files are also supported

wiiznokes avatar Feb 26 '24 15:02 wiiznokes

same problem. Do you have any suggestions for this?

seanchann avatar Mar 13 '24 08:03 seanchann