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

[vs-code-extension] add basic snippets for typespec #4737

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

archerzz
Copy link
Member

  • add snippets for typespec basic constructs
  • package snippets within vs code extension

part of #4559

- add snippets for typespec basic constructs
- package snippets within vs code extension

part of microsoft#4559
@archerzz archerzz requested a review from RodgeFu October 15, 2024 03:00
@azure-sdk
Copy link
Collaborator

azure-sdk commented Oct 15, 2024

All changed packages have been documented.

  • typespec-vscode
Show changes

typespec-vscode - feature ✏️

Add basic snippets for typespec

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs

- typespec-vscode
---

feat(vscode): add basic snippets for typespec
Copy link
Member

Choose a reason for hiding this comment

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

please don't name things like that this ends up in the changelog. THis should be descriptive markdown

Copy link
Member

Choose a reason for hiding this comment

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

same for the pr title in general we don't use that git changelog system so its not really necessary

Copy link
Member Author

Choose a reason for hiding this comment

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

updated changeset and pr title accordingly

{
"Alias": {
"prefix": "alias",
"body": "alias ${1:AliasName} = ${0:Expression};",
Copy link
Member

Choose a reason for hiding this comment

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

I don't know much about snippet but shouldn't those numbers be in order? Do they not map to which one gets filled first?

Copy link
Member Author

@archerzz archerzz Oct 16, 2024

Choose a reason for hiding this comment

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

The sequence starts from 1, 2...

0 is a special index which is always the last one to reach. And when you press Tab to 0, the iteration ends.

If there is no 0, then pressing Tab can start over again when you reach the last placeholder.

Copy link
Member Author

Choose a reason for hiding this comment

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

I put 0 in all snippets, because those snippets have placeholders which may require free-style input, not just a single construct. For example, in the alias definition, the Expression could be a quite long input instead of just a model name.

@microsoft-github-policy-service microsoft-github-policy-service bot added the ide Issues for VS, VSCode, Monaco, etc. label Oct 15, 2024
@archerzz archerzz changed the title feat(vscode): add basic snippets for typespec [vs-code-extension] add basic snippets for typespec Oct 16, 2024
},
"Operation": {
"prefix": ["op", "operation"],
"body": "operation ${1:OperationName}(${2:parameters}): ${0:ReturnType};",
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe for operation, we can change the template to

Suggested change
"body": "operation ${1:OperationName}(${2:parameters}): ${0:ReturnType};",
"body": "operation ${1:OperationName}(${0:parameters}): ${2:ReturnType};",

since the parameters could be multiple inputs

Copy link
Member Author

Choose a reason for hiding this comment

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

On the other hand, the ReturnType could be a union.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ide Issues for VS, VSCode, Monaco, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants