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 snippets provider #870

Merged
merged 1 commit into from
Jun 25, 2024
Merged

Add snippets provider #870

merged 1 commit into from
Jun 25, 2024

Conversation

anderseknert
Copy link
Member

@anderseknert anderseknert commented Jun 25, 2024

Snippets are special inserts that allow users to enter values and press tab to move to the next location.

Untitled.mov

https://code.visualstudio.com/docs/editor/userdefinedsnippets

Add snippets for:

  • some v in coll,
  • some k, v in coll
  • every v in coll
  • every k, v in coll

Got interested in trying this after learning that Zed supports snippets in the latest release. I've tried and confirmed this works in both VS Code and in Zed.

Snippets are special inserts that allow users to enter values and press tab
to move to the next location.

https://code.visualstudio.com/docs/editor/userdefinedsnippets

Add snippets for:
- `some v in coll`,
- `some k, v in coll`
- `every v in coll`
- `every k, v in coll`

Got interested in trying this after learniung that Zed supports snippets in
the latest release. I've tried and confirmed this works in both VS Code and
in Zed.

Signed-off-by: Anders Eknert <[email protected]>
@srenatus
Copy link
Member

Nice how little code is needed to add this 👍

"kind": 15,
"label": "some key-value iteration (snippet)",
"textEdit": {
"newText": "some ${1:key}, ${2:value} in ${3:collection}\n$0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't realise this was so simple, we might want to update things like package completions to use the same format.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally! This should be trivial to extend with more cases. I just wanted to start from somewhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also do things like more advanced function calls (http.send et. al.). where we pre-fill some example values. Like how the VS Code docs have an example where they do this for some AJAX call.

@anderseknert anderseknert merged commit 6cebb1c into main Jun 25, 2024
3 checks passed
@anderseknert anderseknert deleted the snippets branch June 25, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants