vscode-folder-path-color icon indicating copy to clipboard operation
vscode-folder-path-color copied to clipboard

Ability to use regexp?

Open rvt opened this issue 2 years ago • 6 comments

See title :)

rvt avatar Nov 17 '23 13:11 rvt

Feature Request

It would be very interesting if one would be able to define multiple glob patterns like those used in the *.code-workspace and .vscode/settings.json settings:

Notice that VS Code implements its own glob pattern library for performing these file/folder matchings.

Example

Consider these glob patterns in the following example.code-workspace file:


{
	"folders": [
		{
			"path": "."
		}
	],
	"settings": {
		"files.exclude": {
			"**/.git": true,
			"**/.ssh": true,
			"**/.tmp": true,
		},
		"files.watcherExclude": {
			"**/.cproject/*": true,
			"**/.classpath/*": true,
			"**/.buildpath/*": true,
			"**/.gradle/*": true,
			"**/.metadata/*": true,
			"**/target/*": true,
			"**/bin/*": true,
		},
		"search.exclude": {
			"**/__pycache__": true,
			"**/.eggs": true,
			"**/.cache": true,
			"**/.mypy_cache": true,
			"**/.pytest_cache": true,
			"**/*.pyc": true,
			"**/*.egg": true,
		},
	}
}

juarezr avatar Feb 22 '24 15:02 juarezr

Settings

See a suggestion for glob patterns configuration in the following suggestion.code-workspace file:

{
  "folders": [
    {
      "path": "."
    }
  ],
  "settings": {
    "folder-path-color.folders": [
      {
        "tooltip": "Source Files",
        "symbol": "S",
        "color": "green",
        // Keep compatibility
        "path": "src"
      },
      {
        "tooltip": "Documentation",
        "symbol": "D",
        "color": "yellow",
        "path": "docs"
      },
      {
        "symbol": "VS",
        "tooltip": "VS Code Configuration",
        // New multipattern style
        "include": {
          "**/.vscode": true,
          "**/.devcontainer": true,
          "*.code-workspace": true
        }
      },
      {
        "tooltip": "Compiled object files",
        "color": "red",
        "symbol": "B",
        "include": {
          "**/bin": true,
          "**/build": true,
          "**/target": true
        }
      }
    ]
  }
}

juarezr avatar Feb 22 '24 17:02 juarezr

+1 exactly what I whish!

myriamdb avatar Nov 15 '24 13:11 myriamdb

you can also keep the variable as path. If it's a the current way of working. If it's a object, then it's a new way. But even so, src is in the example is not even an blog pattern... so why not simply change the parsing to glob?

rvt avatar Nov 16 '24 10:11 rvt

you can also keep the variable as path. If it's a the current way of working. If it's a object, then it's a new way. But even so, src is in the example is not even an blog pattern... so why not simply change the parsing to glob?

Reasons

There are some advantages of using a using pattern matching rather than exact matching

  1. You can write less configuration entries by matching many repeated directories/files with a pattern rather then explicitly writing the all the paths.
  2. You can reuse the same patterns for all other source code repositories that use the same development languages and folder/file patterns.
  3. You can configure the patterns globally by setting them in the User Settings JSON file.

There are a couple of things that are easier when using pattern matching rather than exact matching:

  1. You can assign/override distinct icons/colors for nested files/folders regardless of was it's parent/root folder is.
  2. You can easily address distinct files/folders mixed in more than one path all at once in the same configuration rule.
  3. Multi-module project repositories tend to have the same sub-directory names distributed inside more than one sub-folder could led to a single set of rules for matching them all at once.

Example

Consider the following directory tree from a hipotetical git cloned repository:

gitcloned
├── ci
│  ├── scripts
│  │  └── setup.sh
│  └── workflows
│     ├── build.yaml
│     └── deploy.yaml
├── docs
│  └── usage.md
├── src
│  ├── bin
│  │  ├── myapp
│  │  └── mylib.so
│  ├── build
│  │  ├── functions.o
│  │  ├── helpers.o
│  │  └── main.o
│  ├── lib
│  │  ├── lib-external.so
│  │  └── lib-interned.so
│  ├── resources
│  │  ├── image.png
│  │  ├── datapoints.csv
│  ├── temp
│  │  ├── build.tmp
│  │  └── generated.tmp
│  ├── build.log
│  ├── functions.c
│  ├── functions.h
│  ├── helpers.c
│  ├── helpers.h
│  ├── main.c
│  └── Makefile
├── temp
│  ├── package.zip
│  └── sketch.txt
├── configure.log
└── readme.md

Notice that if you have the abitily to match files/folders by pattern:

  1. You can make a single rule to mach all temp directories regardless of its parent folders.
  2. You can make a single rule to mach all *.log files regardless of their location.
  3. You can make a single rule to mach all build, lib, resources, and bin directories when the repository have more than one module each one contained in its own subfolder.

juarezr avatar Nov 21 '24 17:11 juarezr

I agree, please add this feature, and keep me updated if it ever gets added. It would be amazing to be able to use glob patterns in this extension, it is already super helpful as is but this would make it even better!

isabellecs avatar Dec 10 '24 08:12 isabellecs