Skip to content

Support "wrap with snippet" #21

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

Closed
pokey opened this issue Jun 23, 2021 · 0 comments · Fixed by #296
Closed

Support "wrap with snippet" #21

pokey opened this issue Jun 23, 2021 · 0 comments · Fixed by #296
Labels
enhancement New feature or request

Comments

@pokey
Copy link
Member

pokey commented Jun 23, 2021

The goal

VSCode has support for snippets that can take a selection. We'd like to use this to enable things such as "if state wrap air", "try state wrap air", etc

Implementation plan

Extension

We propose to add a new action. Check out simple actions like ExtractVariable as a starting point.

The action will call editor.insertSnippet.

We will keep language-specific snippets for each syntactic scope type, similar to how we do for finding containing scope; see eg https://github.com/pokey/cursorless-vscode/blob/fdebfe93c7871a3e3bf832532f51cf64b8f3c3a8/src/languages/python.ts#L46-L68 Note that the snippet will leverage TM_SELECTED_TEXT to refer to where the target that is wrapped will go. We can add tabstops for things like if statement guard, catch block, etc

The action will take an extra arg which is the scopetype to wrap with, eg ifStatement. See Wrap for example of taking extra args

Talon

Add a new capture like "wrap" that accepts a scope type. Something like "<scopeType> wrap <target>"

@pokey pokey added the enhancement New feature or request label Jun 24, 2021
@pokey pokey mentioned this issue Oct 17, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant