We have a custom set of snippets written per-project and would like to include them in the project repo, like our launch.json, tasks.json. Right now we just include the json file and the dev has to copy+paste it into his user snippets, but the snippets are particular to a project, not to all projects.
Also it would be great to have a way to define what extensions a developer should have installed to work on the project. We use several code quality and styling plugins to enforce our custom rules and it would be nice if there was a project definition file to suggest installation of the extensions we define.
@aeschli can you comment on the snippet request. Can't we define snippets on a workspace folder level.
@chrisdias @seanmcbreen for the workspace folder extension request.
A workspace config for extensions is something we are definitely thinking about.
I was writing test cases for extensions and those cases share similar format then I thought I should put a snippet in project settings. But unfortunately I found that's not possible right now.
This can be a good extension as well if we expose Snippet management through API.
I would love to see workspace-level snippets.
This would indeed be amazing. In fact, I found it really unintuitive that there is marketplace-level snippets, but not project level. Took me quite a while to figure out that it wasn't possible. :P
Just for your information, with the new API we added in our latest release 1.8, project/workspace level snippets is now possible. You can use this extension https://marketplace.visualstudio.com/items?itemName=rebornix.project-snippets to share and insert snippets across projects.
Does this plugin still work? Unless I'm doing something wrong, it doesn't seem to be doing anything and there is zero information on it (in the README). I created a snippets folder in .vscode and then created a language specified snippets file within there but that file isn't loaded. I can't use the snippets there.
@jdfwarrior do you mind sharing me part of your snippet then I can have a good reproduce and see what's blocking you :( I know it's not a reasonable request but look forward to your reply.
@rebornix This is all I currently have while testing..
{
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
},
"Angular Controller": {
"prefix": "controller",
"body": [
"export default class $1 {",
" constructor( $2 ) {",
" $0",
" }",
"}"
],
"description": "Create new Angular controller"
}
}
Is there any kind of configuration that needs to be done to make this work?
@jdfwarrior the only thing I'm worried about is tab or space , maybe it's similar to https://github.com/rebornix/vscode-project-snippet/issues/4 as your snippet looks reasonable. I'll reach out to you real quick after fixing that.
@jdfwarrior I've updated the extension. Please let me know if it fixes your problem.
@rebornix seems to work after your March 30th update. Thanks.
@rebornix thanks.
Just an FYI for anyone who finds this ticket, you can now specify recommended extensions for the workspace.
Would love to see workspace-shared snippets!
+1
+1
+1
@rebornix I've been using your extension for workspace snippets for quite some time now (thanks BTW) and I was wondering if there was any plan in the timeline to include this behavior directly inside VSCode ?
@RPDeshaies I kind of like how it works as an extension by leveraging a couple VSCode API. It's up to @jrieken if we want to move similar feature to Code core.
It already works (with an extension)
https://marketplace.visualstudio.com/items?itemName=rebornix.project-snippets
Add a folder snippets
in your project path .vscode
and create a json for the langauge you want. e.g. path: .vscode\snippets\javascript.json
.
Example:
{
"printCustom": {
"prefix": "print",
"body": [
"printCustom('$1');"
],
"description": "Prints text on the terminal console."
}
}
And recommended extension for a project are possible with extensions.json in .vscode.
https://code.visualstudio.com/docs/editor/extension-gallery#_workspace-recommended-extensions
Example .vscode/extensions.json
{
"recommendations": [
"rebornix.project-snippets",
"dbaeumer.jshint"
]
}
Any update on a native solution ?
Any updates? Would be very useful.
I stumbled on this and wrongfully expected that a *.code-snippet
file in .vscode
folder would be considered. is that planned ?
September issue cleansing.
This is well covered by an extension and we have no plans to bundle this extension with VS Code.
Reopening... this is not out of scope according to our guidelines https://github.com/Microsoft/vscode/wiki/Issue-Grooming#out-of-scope-feature-requests
Reopening... this is not out of scope according to our guidelines https://github.com/Microsoft/vscode/wiki/Issue-Grooming#out-of-scope-feature-requests
Even better: this will happen in September!
Good news: Current Insiders has a rough version of this already and with next Insiders this will be working. This is how:
.vscode
-folder of your workspace (but not inside subfolders of that).code-snippets
extension are supportedThank you! This is why we love VS Code
Thanks, team!
you can put snippets in the
.vscode
-folder of your workspace (but not inside subfolders of that)
@jrieken Love this, but can we expect support for subfolders? (best way .vscode\snippets\*.code-snipets
).
@Ash258 We are always a little scared of subfolders because there might be many, many...
馃殌 love this feature, my extension can retire now and I don't need to fix all those issues 馃槅 . I'll put my name on the test item to ensure they get tested.
Went through https://github.com/rebornix/vscode-project-snippet/issues and test cases of vscode-project-snippet, didn't find any issue at all, the builtin support is solid 馃憤
Most helpful comment
A workspace config for extensions is something we are definitely thinking about.