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

[Idea] Create auto group based on files.exclude #8

Open
thomascamminady opened this issue Aug 1, 2023 · 9 comments
Open

[Idea] Create auto group based on files.exclude #8

thomascamminady opened this issue Aug 1, 2023 · 9 comments

Comments

@thomascamminady
Copy link
Contributor

Awesome extension! I really like it and I think you're doing a great job here.

I have one idea where I don't know how difficult it would be to implement and whether this is even a use case that more people encounter.

I'm frequently having projects with many project files / hidden files / dot files. Here's how that could look like:

image

Now if I add some of these files in my files.exclude section in the settings.json like this

image

AND add them to File Focus, I can organize my workspace nicely:

image

I really like this. This makes everything much more organized in my opinion. It does even solve an issue that has been thoroughly discussed on HackerNews.

So my idea/question: Would it be possible to add a setting that is something like: "Automatically create focus group from excluded files". Then, if toggled, a focus group "Excluded" (or some other name) is created. This should add all files in the files.exclude section of the settings.json, even if their flag is set to false and not true. This would allow to have this setup that I have shown above out of the box.
Implementation wise I am not sure if this is difficult or not. I am not a TS developer, but I am willing to try to help if that's something that would bring this feature to live.

Happy to hear your opinion :)

@thomascamminady
Copy link
Contributor Author

Maybe I should have read the documentation better. Using the filefocus.json file, this is how far I get:

image

So I could just place that file inside my repositories. The only issue is that it might be better to skip the files that don't exist instead of showing the "triangle".

@thomascamminady
Copy link
Contributor Author

Maybe this could be solved by adding a check in the addResource function:

  /**
   * Add a resource (file/folder) to the group.
   * @param uri The vscode.URI of the resource.
   */
  public addResource = (uri: Uri) => {
    if (this._resourceContains(uri)) {
      return;
    }
    if (file_does_exist(uri)){ // or however this looks like in TS
      this._resource.push(uri);
    }
  };

@quicken
Copy link
Owner

quicken commented Aug 1, 2023

Heya, thanks for the feedback. I really like your idea and just spotted your PR. I'm pretty busy at work at the minute but will make time on the weekend to review and merge. Thanks again for your effort much appreciated.

@thomascamminady
Copy link
Contributor Author

Thanks for the reply. This does not have any urgency, so take your time.
Also, full disclosure, I created the code in the PR with GPT4. I don't know any Typescript and while I tested the code and it seemed to work, feel free to reject the PR and implement it correctly if I did it wrong.

@quicken
Copy link
Owner

quicken commented Dec 15, 2023

Hi,
I have picked up on your ideas and added the concept of Dynamic Groups to the extensions. Dynamic Groups are read-only groups that get automatically populated based on some rules.

In the current master branch, I have enabled the following two algorithms.

1) Exclude Group

The excluded group can be enabled in the settings of the extension (requires restarting vscode to pick up changes).

When enabled a Dynamic Group named "Excluded" is added to the extension the group automatically shows any files and folders that match the glob patterns defined inside the files.exclude file.

2) Glob Groups.

It is now possible to define Dynamic Groups based on glob patterns. This should provide a lot of flexibility of what is possible to automatically group. See the readme for more information.

You can grab the pre-release from the git hub releases tab which should be on the right-hand side when viewing this repo.

There are some other improvements, have a look at the readme in the project root.

Unless I find some major issues I should be releasing this version to the marketplace in the next week or two. Feel free to give the pre-release a try and let me know what you think.

Once again thanks for the feedback and helping to improve the extension.

@thomascamminady
Copy link
Contributor Author

Hey there!
Thanks so much for getting back at this. I have a look at this and hope to be able to try this out in the coming days.
Thank you so much for solving this particular wish of mine :)

@quicken
Copy link
Owner

quicken commented Dec 18, 2023

Thank the flooding and cyclone in Cairns. On holidays with nowhere to go. So plenty of time to code. :) :)

I liked the suggestion as it led to a new feature where you can now define dynamic folders based on glob patterns.

There are still some little niggles because I can't access vscodes own glob implementation and I have to use another library that works slightly differently.

Just post any issues and they should be easy to fix. Just grab the latest build I have published from git hub it will be some 1.5.x version.

@thomascamminady
Copy link
Contributor Author

Thanks for the update, I downloaded the latest version and want to give it a try. However, I'm too stupid to figure out how to set up the dynamic exclude group.

"files.exclude": {
        "**/__pycache__": true,
        "**/.git{,/**/*}": true,
        "**/.mypy_cache/**": true,
        "**/.pytest_cache/**": true,
        "**/.ruff_cache/**": true,
        ".readthedocs.yml": true
    },

These are my excluded files and I would like them to show up in a File Focus group. Could you maybe show me how to add the dynamic group? Thanks!

@quicken
Copy link
Owner

quicken commented Dec 18, 2023

So two options.

The first option, go to settings and tick the setting: "Show Excluded Group". Then restart VSCode. You should then see a group that will automatically contain anything defined inside "files.exclude".

The second option is to define your own filters. Go to settings and look for "Glob Group". Then click "edit in settings json"

Within the [] you can put the following configuration.

 {
      "name": "Hidden Files",
      "include": ["**/.*"],
      "exclude": ["**/node_modules/**", "**/.git{,/**/*}"],
      "recurse": true
}
You can put multiple of these separated with a comma and each one will show as a group with whatever rules you have defined. The above example would add a DynamicGroup named Hidden files that show all . files in all workspaces except for those inside the .git and node_modules folders.

Of course you can modify the patterns to whatever you want, notice that you can specify multiple pattern for both include and exclude as has been done in the example for exclude.

You might also need to restart VSCode to pick up those changes.

It would then look something like this:

  "filefocus.globGroup": [
  
    {
      "name": "Hidden Files",
      "include": ["**/.*"],
      "exclude": ["**/node_modules/**", "**/.git{,/**/*}"],
      "recurse": false
    }
  ],

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

No branches or pull requests

2 participants