-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Description
Global snippets already support being scoped by language and language file snippets are naturally scoped. I would like to expand that "scoping" logic to specific files by matching the filename, for example.
A good use case for this, let's say I want to create snippets for travis.yml file. Right now what I do is to create the snippet scoped to YAML language.
The problem is that it will appear for every YAML file which will pollute the autocomplete with not very useful results if you have snippets for multiple kinds of files that have the same extension. (I don't want to see "travis" related snippets in a "gitlab-ci.yml" file for example) as they are not applicable.
I think this is most critical for configuration files where they have a very specific scope and that you can easily restrict by looking at the filename.
Going further, we could even expand this concept for other kinds of snippets. For example, I can have some project level snippets for building queries and I only want to enable them, in Repository classes and not in Controller classes. You could scope the files it applies using a regex pattern, for example.
I guess this shouldn't be very hard to do and it would vastly improve the suggestions quality of the snippets.
I see adding a new field similar to "scope" called "context" or something where you can specify a regex that will match to the filename.