Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust-analyzer.files.excludeDirs is not working #7755

Closed
lnicola opened this issue Feb 22, 2021 · 12 comments · Fixed by #12341
Closed

rust-analyzer.files.excludeDirs is not working #7755

lnicola opened this issue Feb 22, 2021 · 12 comments · Fixed by #12341
Labels
C-bug Category: bug E-has-instructions Issue has some instructions and pointers to code to get started S-actionable Someone could pick this issue up and work on it right now

Comments

@lnicola
Copy link
Member

lnicola commented Feb 22, 2021

Unfortunately this didn't seem to help. I added .rustwide and .rustwide-docker to rust-analyzer.files.excludeDirs and reloaded VSCode, but RA is still using over 2 GB (when most other people were only seeing about 1.3 GB used).

Originally posted by @jyn514 in #7451 (comment)

@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Feb 22, 2021
@matklad matklad added the E-has-instructions Issue has some instructions and pointers to code to get started label May 24, 2021
@64kramsystem
Copy link

64kramsystem commented Jun 30, 2021

Doesn't work also for me; the documentation doesn't say much, so I'm not sure if I need to set the value in a specific way.

My project layout is:

.
├── breakout_example
├── resources -> ../resources/boing
├── src

inside breakout_example there is a breakout.rs file. I can't find any way to exclude it from rust-analyzer (I just need it the syntax highlight).

This is the related setting:

    "rust-analyzer.files.excludeDirs": [
      "**/breakout_example"
    ]

I think it should work, because that's the standard VSC definition. I've tried alternatives, but I couldn't find any way to exclude it.

@lnicola
Copy link
Member Author

lnicola commented Jun 30, 2021

Not that I don't believe you, but can you say how you are testing? I'm asking because we set these up in a couple of places (file change notifications, file saves and something else too -- project load?).

matklad's comment above about not handling exclusions seems relevant. That's the file watcher registration.

@64kramsystem
Copy link

Not that I don't believe you, but can you say how you are testing? I'm asking because we set these up in a couple of places (file change notifications, file saves and something else too -- project load?).

matklad's comment above about not handling exclusions seems relevant. That's the file watcher registration.

Hello! Thanks :) Let me create the simplest test case and I'll get back (tomorrow or the day after); hopefully, simplifying the current project will show more clearly where the problem is.

@64kramsystem
Copy link

64kramsystem commented Jun 30, 2021

It seems to be a more complex problem.

What I'm observing is (with the directory excluded):

  • I open the VSC workspace, and open the file in the editor
  • I close the VSC workspace, then reopen it
  • at the very beginning, the file is not marked with any error
  • at some point during the RA indexing, the error is added to the file (file not included in module tree)
  • I close the file, then reopen it
  • no more error!
  • I change the file with a permanent change, e.g. add const PIZZA: i32 = 1;, and save
  • the error appears again
  • I close the file, then reopen it
  • no more error!

If I change the file with a change that is reverted by the autoformatter (e.g. add a space after the terminal ; of a statement), the error does not appear again.

@64kramsystem
Copy link

Not that I don't believe you, but can you say how you are testing? I'm asking because we set these up in a couple of places (file change notifications, file saves and something else too -- project load?).

matklad's comment above about not handling exclusions seems relevant. That's the file watcher registration.

Hello!

Here's a minimal test case:

cargo new mytest2
cd mytest2

mkdir excl
echo abc > excl/abc.rs

mkdir .vscode
cat > .vscode/settings.json << 'JSON'
{
  "rust-analyzer.files.excludeDirs": [
    "**/excl"
  ]
}
JSON

# after the first command, switch back to the terminal
code .
code excl/abc.rs
# now, in VSC, abc.rs shows the error

@symil
Copy link

symil commented Jul 5, 2021

I have the same issue. I have a blueprint-templates folder at the root of my project that contains some files that serve as templates. These files include stuff like {{ $myVar }} that are meant to be replaced when a file is created, so they're full of errors. I tried every possible combinations in "rust-analyzer.files.excludeDirs", but I can't seem to get rust-analyzer to ignore the folder.

EDIT: the file is ignored as long as it is not open in the editor.

dae added a commit to ankitects/rust-analyzer that referenced this issue Jul 19, 2021
I saw reference to globs in rust-lang#7755, but it doesn't look like they're
actually supported, and I had to dig through the source to discover
that the folders are relative to the workspace root. Further digging
was required to get VS Code from hanging for long periods trying to
watch giant Bazel folders that had already been excluded from Rust
Analyzer. Hopefully this tweak will save others the confusion :-)
dae added a commit to ankitects/rust-analyzer that referenced this issue Jul 19, 2021
I saw reference to globs in rust-lang#7755, but it doesn't look like they're
actually supported, and I had to dig through the source to discover
that the folders are relative to the workspace root. Further digging
was required to get VS Code from hanging for long periods trying to
watch giant Bazel folders that had already been excluded from Rust
Analyzer. Hopefully this tweak will save others the confusion :-)
bors bot added a commit that referenced this issue Jul 22, 2021
9634: minor update to excludeDirs doc r=lnicola a=dae

I saw reference to globs in #7755, but it doesn't look like they're
actually supported, and I had to dig through the source to discover
that the folders are relative to the workspace root. Further digging
was required to get VS Code from hanging for long periods trying to
watch giant Bazel folders that had already been excluded from Rust
Analyzer. Hopefully this tweak will save others the confusion :-)

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
@yukitaka13-1110
Copy link

Any update?

@jyn514
Copy link
Member

jyn514 commented Jul 31, 2021

@yukitaka13-1110 My understanding is someone still needs to investigate why this doesn't work: #7755 (comment)

@paveloom
Copy link

Seems to be especially relevant when developing Flatpak applications: see #8161.

@polyjitter
Copy link

Still dealing with this... still no way to do this? Also trying to work with flatpaks and makes autocompletion just not exist.

@paveloom
Copy link

paveloom commented Jul 18, 2022

@polyjitter Do you use flatpak-builder? Ignoring the .flatpak-builder directory works for me:

-- A snippet from my Neovim config
-- <...>
server = {
    standalone = false,
    settings = {
      ["rust-analyzer"] = {
        files = {
          excludeDirs = { ".flatpak-builder" }
        },
        -- <...>
      },
    }
  },
-- <...>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug E-has-instructions Issue has some instructions and pointers to code to get started S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants