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

enable only for certain files #3

Open
tomasc opened this issue Apr 25, 2023 · 1 comment
Open

enable only for certain files #3

tomasc opened this issue Apr 25, 2023 · 1 comment

Comments

@tomasc
Copy link

tomasc commented Apr 25, 2023

Thanks for making this extension, very useful!

I am not well-versed in setting up extensions, however I wonder whether it would be possible to add optional configuration, that would allow to enable the snippets only for matching files?

Typically Faker is used only in test files, so I would love to have these snippets enabled only for *_test.rb.

Perhaps it's a simple addition. Otherwise I can also try to make a PR.

@giancarlopro
Copy link
Owner

One workaround would be to define a new language named rubytest to target *_spec.rb and *_test.rb files, and scope the snippets to it.

Since vscode allows to associate extensions to languages it would also be possible to extend it to other file extensions.

Something like:

"contributes": {
    "languages": [
        {
            "id": "rubytest",
            "aliases": ["Ruby Test", "rubytest"],
            "extensions": ["_test.rb", "_spec.rb"],
            "configuration": "./language-configuration.json"
        }
    ]
}

The problem is it would not work on factory bot factories or similar libs out of the box. We would need to change user settings, or include steps on the readme, to associate files inside spec or test folders to rubytest lang.

A toggle button would also be a solution, but i sincerely don't know which is the best solution, do you have any other ideas?

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