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 transformations to snippets variables #6920

Closed
zpdDG4gta8XKpMCd opened this issue May 26, 2016 · 9 comments
Closed

Add transformations to snippets variables #6920

zpdDG4gta8XKpMCd opened this issue May 26, 2016 · 9 comments
Assignees
Labels
feature-request Request for new features or functionality on-testplan release-notes Release notes issues snippets

Comments

@zpdDG4gta8XKpMCd
Copy link

TextMate snippets page says:

7.7 Transformations

There are situations where we want our placeholder text mirrored but with slight changes or where we want some text to appear depending on the value/presence of a placeholder.

We can accomplish this by doing a regular expression substitution on the placeholder text (when mirroring it). The syntax for this is: ${«tab stop»/«regexp»/«format»/«options»}.

It looks like transformations are not supported in VS Code. Would be a great addition.

@aeschli aeschli self-assigned this May 27, 2016
@aeschli aeschli added the feature-request Request for new features or functionality label May 30, 2016
@aeschli aeschli added this to the Backlog milestone May 30, 2016
@aeschli aeschli changed the title add transformations to snippets [snippets] add transformations to snippets May 30, 2016
@jrieken jrieken self-assigned this Dec 27, 2016
This was referenced Feb 6, 2017
@sunabozu
Copy link

Are there any news about it?

@mpearon
Copy link

mpearon commented May 12, 2017

Has there been any headway made on this issue, or has it been prioritized?

@jhickson
Copy link

This would be great to have - is it likely to be implemented soon?

@jrieken
Copy link
Member

jrieken commented May 18, 2017

Maybe... I am doing some snippet work this month, but not exclusively. We have enabled multi cursor support which I believe was the number 1 complained. Next could be nested snippets (invoke snippets when completing a snippet), choice support and transforms.

@royprocops
Copy link

Same request as others here. I would like a snippet to generate boilerplate for my React components, based off of the filename without the filename extension. Either need another variable for filename without file extension, or regular expressions to transform the filename.
Thanks!

jrieken added a commit that referenced this issue Jul 14, 2017
@ghost
Copy link

ghost commented Jul 24, 2017

I, too, miss the feature to use the filename without the extension in a snippet. Perhaps you could add $TM_FILENAME_BASE as a workaround until this feature gets implemented?
Thanks!

@joelpresence
Copy link

I would love this for creating go test files. For example, if I'm in a go package a/b/c, I put my tests for package c in a/b/c/tests, its own tests package.

I have a created a snippet like the following in go.json:

{
	"Test file": {
		"prefix": "tt",
		"body": [
			"package tests",
			"",
			"import (",
			"\t\"github.com/stretchr/testify/assert\"",
			"\t. \"a/b/$1\"",
			")",
			"",
			"func Test$2(t *testing.T) {",
			"\tassert := assert.New(t)",
			"",
			"\t$0",
			"}"
		],
		"description": "Create a new test file"
	}
}

which produces

package tests

import (
	"github.com/stretchr/testify/assert"
	. "a/b/"
)

func Test(t *testing.T) {
	assert := assert.New(t)

	
}

However, if I'm in a file a/b/c/tests/foo_test.go when I expand this snippet, then the line . "a/b/" should be . "a/b/c" because these are tests for the the c package.

How do I accomplish this?

I tried using TM_DIRECTORY but it doesn't seem that I can manipulate it to remove trailing cruft. Nor can I use workspaceRoot ...

I'd really like to have access to the "parent package" but being able to manipulate the current filename with knowledge of workspace root would probably be good enough.

Will the fix mentioned in this issue support my use case (pretty common for go developers) and is there an ETA? :-)

Thanks!

@jrieken
Copy link
Member

jrieken commented Sep 8, 2017

fyi - I have just merged #33253 which is about snippet transformations for snippet variables.

@jrieken jrieken changed the title [snippets] add transformations to snippets Add transformations to snippets variables Sep 20, 2017
@jrieken
Copy link
Member

jrieken commented Sep 20, 2017

If have re-purposed this issue to be about snippet transformation for snippet variables. For transformations of snippet placeholders i have created #34683. Variable transformations will ship in September.

@jrieken jrieken closed this as completed Sep 20, 2017
@jrieken jrieken mentioned this issue Sep 25, 2017
2 tasks
@aeschli aeschli removed their assignment Sep 25, 2017
@jrieken jrieken added the release-notes Release notes issues label Sep 29, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
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 on-testplan release-notes Release notes issues snippets
Projects
None yet
Development

No branches or pull requests

8 participants