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

Project-specific settings for including / excluding directories and files #5443

Closed
JosephTLyons opened this issue Jun 14, 2022 · 28 comments
Closed
Labels
enhancement [core label]

Comments

@JosephTLyons
Copy link
Collaborator

JosephTLyons commented Jun 14, 2022

Depending the project, there is quite a bit of noise in some of my file searches. I would like to be able to exclude some directories (virtual environment directories, npm module directories, etc.) from being searched through when using command+p to find a file, to remove as much noise as possible. I'm guessing this implies some sort of project settings? I think it could just be as simple as a hidden json file, that gets committed with your project, that excludes items via patterns:

A small example might be:

{
    "excluded_patterns": [
        "<some-path-prefix-starting-from-project-root>/some_specific_file.py"
        "<some-path-prefix-starting-from-project-root>/some_specific_director/*",
        "*.scss"
    ],
}

Some open-ended questions about this:

  1. When a directory is added to an exclusion list in a project setting file, what all is affected?

    • Does it affect what shows up in the file browser on the left?
    • Does it affect searches?
    • Does it affect searching for files?
    • etc.

    Or are all of those separate project settings?

@zcaceres
Copy link

Same problem in my Typescript projects. .gitignore'd directories still are included in cmd+p call. For projects with big node_modules this makes the file search almost unusable.

@JosephTLyons
Copy link
Collaborator Author

Something else to consider: Maybe there is a global set of excluded patterns in the normal settings, things that are always in the same location and always excluded no matter the project, then additional per-project settings to customize the excluded items further.

@nathansobo
Copy link
Contributor

nathansobo commented Jun 20, 2022

Going to prioritize this to start building in the coming weeks.

@exalted
Copy link
Contributor

exalted commented Jul 11, 2022

I hope as part of this effort there will be also support for user-specific (aka SCM-ignored) VS team-shared (committed to SCM) settings files.

Example:

  • ~/.zed/settings.json would contain user-only settings and apply to everything edited with Zed
  • ~/foo-project/.zed/settings.json would be included in SCM and shared across all members of the foo-project
  • ~/bar-project/.zed/usersettings.json would NOT be included in SCM therefore only apply to bar project and for the local user only.

@hueys
Copy link

hueys commented Sep 24, 2022

It would be nice to be able to ignore files and directories in the Project Panel (file tree) similarly either on a global or per-project basis.

@WindSoilder
Copy link
Contributor

For python projects, different project may use different formatter, or different code style, it would be nice to support configure these information each project, and if the setting is not found, fallback to user level setting

@jasikpark
Copy link

++ since cargo-fuzz workspaces aren't picked up automatically by rust-analyzer, so like in VSCode, I need to tell rust-analyzer to look at /$CRATE/fuzz/Cargo.toml manually.

ex: https://github.com/kaleidawave/ezno/tree/main/parser/fuzz

@abey79
Copy link

abey79 commented Mar 17, 2023

For python projects, different project may use different formatter, or different code style, it would be nice to support configure these information each project, and if the setting is not found, fallback to user level setting

Exactly. Like many, I can't live without "Black on save" for my python projects. However, I can't allow that to happen when working a third-party project which doesn't use Black, as I occasionally do. Without per-project settings, this would be rather cumbersome to deal with.

@stewarthsoj
Copy link

stewarthsoj commented Apr 30, 2023

I'd like the ability to configure formatters at a project-level and default to the local installations of that formatter.

Another feature from VSCode, which I found useful, was explorer.excludeGitIgnore. This hid files in the file tree that were included in the project's .gitignore file. Most of the time I wasn't referencing these files, so it was fine to hide them.

@exalted
Copy link
Contributor

exalted commented Jun 15, 2023

I think the title of this issue may be misleading, because project-specific settings file support has been just shipped in v0.90.1, whereas this issue is mostly requesting to add a new setting which excludes files.

@JosephTLyons
Copy link
Collaborator Author

JosephTLyons commented Jun 16, 2023

I think the title of this issue may be misleading, because project-specific settings file support has been just shipped in v0.90.1, whereas this issue is mostly requesting to add a new setting which excludes files.

I adjusted the title to be more specific to what the body is asking.

@JosephTLyons JosephTLyons changed the title Project-specific settings file Project-specific includes / excludes Jun 16, 2023
@JosephTLyons JosephTLyons changed the title Project-specific includes / excludes Project-specific settings for including / excluding directories and files Jun 16, 2023
@jezikk
Copy link

jezikk commented Jul 21, 2023

VSCode default patterns for excluded files / folders:

**/.git
**/.svn
**/.hg
**/CVS
**/.DS_Store
**/Thumbs.db

@gldtn gldtn mentioned this issue Jan 24, 2024
17 tasks
SomeoneToIgnore referenced this issue Nov 17, 2023
* Part of https://github.com/zed-industries/community/issues/70

Allows to fully remove from Zed certain files or file groups: no items
will be scanned or added into worktrees, so nothing will be shown in
project tree, project search and go to file would not see those,
corresponding FS events will be ignored.

One exclusion is .git files: those are still not shown or accessible by
default, yet tracked in the worktrees.

By default, is configured to 
```json
  "file_scan_exclusions": [
    "**/.git",
    "**/.svn",
    "**/.hg",
    "**/CVS",
    "**/.DS_Store",
    "**/Thumbs.db",
    "**/.classpath",
    "**/.settings"
  ],
```

* In addition, contains code preparations for "search in included files"
feature: new SearchOptions variant, search crate and RPC adjustments

Release Notes:

- Added `file_scan_exclusions` section to project settings to completely
ignore certain files in Zed
@SomeoneToIgnore
Copy link
Contributor

Zed 0.114.1 got a settings knob to exclude certain files, defaults use the proposed above exclusions list:

// Add files or globs of files that will be excluded by Zed entirely:
// they will be skipped during FS scan(s), file tree and file search
// will lack the corresponding file entries.
"file_scan_exclusions": [
"**/.git",
"**/.svn",
"**/.hg",
"**/CVS",
"**/.DS_Store",
"**/Thumbs.db",
"**/.classpath",
"**/.settings"
],

Any file that matches the exclusions is now entirely excluded from Zed and should not be visible in project tree, file finder or anywhere else.
Zed also does not traverse gitignored directories now, so node_modules/ contents is not indexed by default and does not pop up in search results either.

Seems that the majority of the things mentioned here are implemented now, so I'll close this issue.
Let's deal with inclusions and other related things in follow-up issues with more relevant details.

@David-Portillo
Copy link

David-Portillo commented Feb 15, 2024

is https://zed.dev/docs/getting-started documentation updated? I tried finding a combination of "file_scan_exclusions" and I wasn't able to

@SomeoneToIgnore
Copy link
Contributor

I think there's none, so please submit a PR with tue adjustments 🙂

@nikuz
Copy link

nikuz commented Feb 25, 2024

Thank you for adding this feature. It truly helps.

But I discovered an issue which is kind of a deal breaker in cases when you have projects with different directory structure and naming convention.

Defining the file_scan_exclusions in Folder-specific settings doesn't have any effect. So, I can't specify project specific directories to be excluded, otherwise they appear to be hidden in any other project I open in Zed editor.

@SomeoneToIgnore
Copy link
Contributor

Great catch (albeit seems hard to implement?).
If you could add an issue with some basic example, it would be really great — otherwise we risk having it forgotten in this closed issue.

@nikuz
Copy link

nikuz commented Feb 26, 2024

@SomeoneToIgnore is it possible to reopen this particular issue? Since the name of this one states "Project-specific settings", but the feature was implemented as global.
I would open a new one, but the name would be pretty much the same.

@SomeoneToIgnore
Copy link
Contributor

Indeed we can, but the main part of my message is to get an example of such project-specific files/directories that are ok to have in one project and not ok in another.

As mentioned, it's somewhat tricky to implement potentially, and thinking of it more without your part of the context makes me wonder: why would anybody exclude .DS_Store-like garbage (or project-specific build files, etc.) from one project and keep in another?
Some real-life example would help me to understand it better — maybe there are other ways, or, at least, this way I'm able to test it without setting some synthetic set-up.

@nikuz
Copy link

nikuz commented Feb 26, 2024

@SomeoneToIgnore sure, the reason I discovered this issue is that I tried to search something in my codebase and I was getting unwanted results from my docs directory. I have some mock files in there with real data my app receives from the API. So I wanted to exclude that folder from search only (I actually would prefer to have that folder still visible in the file explorer but it's a topic for another discussion).

So the way to do the exclusion I discovered is described in this issue - define a file_scan_exclusions setting option. It works, now I don't get the results from docs directory. But when I open another project (which also is having a docs directory in it) I would prefer to have that directory visible perhaps.

So, possibly I misuse this setting and there is another way to exclude files and directories from search? If yes, then it's totally fine to have the file_scan_exclusions universal for all the projects and have there only garbage and build output files.

@SomeoneToIgnore
Copy link
Contributor

You're certainly misusing it! So glad that we've discussed it further before doing anything 🙂

There's a "Toggle filters" button in the project search:
image
that contains the Exclude: field which should do what you've described.

In addition to that, project panel allows to narrow the search with a particular directory:
image

While those things may also have bugs, I do not think that a static file_scan_exclusions is a good choice for your use case.

@nikuz
Copy link

nikuz commented Feb 26, 2024

Ah, I saw those. They are handy. But they don't remember your choices, so you need to fill them up every time you do the search. Which defies a purpose of fast search.

@nikuz
Copy link

nikuz commented Feb 26, 2024

Search inside is also good. But I would still prefer to exclude some directories from scanning and search as Jetbrains IDEs do. You simply right click on a folder and mark it as excluded for this project.
Screenshot 2024-02-26 at 3 36 49 PM

@SomeoneToIgnore
Copy link
Contributor

Yes, persistence for them is lacking for now, alas, we should improve it.

@markbrown4
Copy link

Sorry if this has been answered already, how can I surface .gitignore'd files in "Search project files..."?

@SomeoneToIgnore
Copy link
Contributor

There's a button under the search filters (note the filter button toggled on the screenshot, opening the inputs below it) to include them into the search results:

image

@markbrown4
Copy link

Thanks, I'm referring to "Search project files..." to find a file by filename rather than contents.

@SomeoneToIgnore
Copy link
Contributor

Oh, I see now: there's no such thing yet and here's an issue for it: #4745

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [core label]
Projects
None yet
Development

No branches or pull requests