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

[snippets] Support snippet contribution on a specific file #3125

Closed
dbaeumer opened this issue Feb 18, 2016 · 8 comments
Closed

[snippets] Support snippet contribution on a specific file #3125

dbaeumer opened this issue Feb 18, 2016 · 8 comments
Assignees
Labels
feature-request Request for new features or functionality snippets

Comments

@dbaeumer
Copy link
Member

I would like to contribute snippets to .vscode/tasks.json. However currently I can only contribute snippets using the snippet extension point on a language mode.

@felixfbecker
Copy link
Contributor

I think an additional filter setting would be nice, that accepts a glob. So snippets (custom ones too) could be scoped to tasks.json, package.json, .vscode/*.*, gulpfile.*, test/**/*.* etc etc

@aeschli aeschli added this to the Backlog milestone Feb 22, 2016
@aeschli
Copy link
Contributor

aeschli commented Feb 22, 2016

@dbaeumer This is about completion in task.json, right?
The mechanism for that are the default values in the task.json schema. The variable syntax ('{{..}}' is supported there as well. If what we have is not good enough, then we should rather extend the support there. Snippets are not context sensitive.

@felixfbecker
Copy link
Contributor

@aeschli it's not about default values for keys, it's for entire snippets, for example an entire task configuration for a build task that a language extension can contribute. Or simply snippets that only show up in specific files, see my examples.

@aeschli aeschli changed the title Support snippet contribution on a specific file [snippets] Support snippet contribution on a specific file Feb 24, 2016
@dbaeumer
Copy link
Member Author

dbaeumer commented Mar 1, 2016

@aeschli I would for example like to insert the following lines:

    "version": "0.1.0",
    "command": "tsc",
    "isShellCommand": true,
    "showOutput": "silent",
    "args": ["-p", "."],
    "problemMatcher": "$tsc"

How would I do that with default values and how would I provide more than one default value the user can pick from ?

@aeschli
Copy link
Contributor

aeschli commented Mar 1, 2016

@dbaeumer Schemas now support a 'defaultSnippets' property.
Check out src/vs/workbench/parts/snippets/electron-browser/snippets.contribution.ts, line 135.
It's an array of snippets, using our internal snippet syntax ({{...}}). label and description are optional.
You can add them top level, but also for arrays and objects deeper down in the JSON structure..

Let me know if that suits your needs.

@waderyan
Copy link

waderyan commented Mar 2, 2016

👍

@aeschli aeschli assigned jrieken and unassigned aeschli Nov 20, 2017
@jrieken jrieken removed this from the Backlog milestone Nov 21, 2017
@jrieken
Copy link
Member

jrieken commented Dec 11, 2017

@dbaeumer Is this still needed given @aeschli's support for default snippets in schemata?

@dbaeumer
Copy link
Member Author

I started using the default snippet support from the JSON schema.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality snippets
Projects
None yet
Development

No branches or pull requests

5 participants