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

Add when/context support for snippets in packages.json #26943

Closed
DanTup opened this issue May 19, 2017 · 5 comments
Closed

Add when/context support for snippets in packages.json #26943

DanTup opened this issue May 19, 2017 · 5 comments
Assignees
Labels
snippets under-discussion Issue is under discussion for relevance, priority, approach

Comments

@DanTup
Copy link
Contributor

DanTup commented May 19, 2017

Currently snippets defined in packages.json are only filtered by language (as far as I can tell):

"contributes": {
    "snippets": [{
        "language": "dart",
        "path": "./snippets/dart.json",
    }]
}

I would like to add some additional snippets but they're only relevant to a subset of Dart projects (Flutter) so it'd be nice if we were able to add contexts to snippet contribution like we can with commands:

"contributes": {
    "snippets": [{
        "language": "dart",
        "path": "./snippets/flutter.json",
        "when": "dart-code:flutterProjectLoaded"
    }]
}

I know we could do this by adding them to the completion provider, but that seems like significant complexity when there's nothing dynamic, we just want a toggle for the whole file.

@jrieken jrieken added the feature-request Request for new features or functionality label May 22, 2017
@jrieken
Copy link
Member

jrieken commented May 22, 2017

Unsure... There is little desire to add more complexity to static snippet because we thing adding a completion provider isn't much overhead

@DanTup
Copy link
Contributor Author

DanTup commented May 22, 2017

I don't think it's totally trivial to go from a declarative json file to programming a completion provider, but maybe it's easier than I think?

Do I need to look at the typed characters and filter the list, or can I just send all my snippets all of the time via the completion provider?

@jrieken
Copy link
Member

jrieken commented May 23, 2017

Just sending them should do it. The UI filters then using the current word

@DanTup
Copy link
Contributor Author

DanTup commented May 23, 2017

Ok great, maybe much simpler than I thought :-)

@jrieken jrieken added under-discussion Issue is under discussion for relevance, priority, approach and removed feature-request Request for new features or functionality labels Jun 27, 2017
@jrieken
Copy link
Member

jrieken commented Jun 27, 2017

We have no plans of doing, especially considering being able to add some sort of scope information to snippets (see #22661) and that extensions can do much more.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
snippets under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

3 participants