Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Support for Snippet prefix and other values inside Snippet's body #270

Open
duckz0r opened this issue Jul 19, 2018 · 1 comment
Open

Support for Snippet prefix and other values inside Snippet's body #270

duckz0r opened this issue Jul 19, 2018 · 1 comment

Comments

@duckz0r
Copy link

duckz0r commented Jul 19, 2018

I am trying to develop a snippet in which i can use in the body, the snippets prefix, description and/or other values.

For example:

"Snippet x": {
        "prefix": "<my-snippet-prefix>",
	"description": "A prototype of a snippet",
	"types": "html",
	"inputs": ["input1", "input2"],
	"outputs": ["output1", "output2"],
	"body": [
		"<@prefix>",
		"\t${1|@inputs|}",
                "\t${2|@outputs|}",
                "$3",
		"</@prefix>$0"
	]
}

The point is basically to be able to define values like inputs and outputs (e.g. read from a .txt file and writen on the .json file) instead of writting it all down like:

        "prefix": "<my-snippet-prefix>",
	"description": "A prototype of a snippet",
	"types": "html",
	"body": [
		"<my-snippet-prefix>",
		"\t${1|'input1', 'input2'|}",
                "\t${2|'output1', 'output2'|}",
                "$3",
		"</my-snippet-prefix>$0"
	]

I don't think this is supported yet, nor the ability to press Ctrl+Space in the code and, within the selected snipped, be able to choose its parameters/values. Is it something doable or am I just missing something?

@savetheclocktower
Copy link
Contributor

This isn’t supported as a built-in feature of snippets. But you can write a command that collects parameters in whatever manner you please and writes the output as a snippet. Here’s an example of how to insert the result of a command as a snippet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants