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

Merged
merged 11 commits into from
Oct 23, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- typespec-vscode
---

Add basic snippets for typespec
1 change: 1 addition & 0 deletions packages/typespec-vscode/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ dist/test/
!ThirdPartyNotices.txt
!LICENSE
!icons/
!snippets.json
9 changes: 8 additions & 1 deletion packages/typespec-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"publisher": "typespec",
"displayName": "TypeSpec for VS Code",
"categories": [
"Programming Languages"
"Programming Languages",
"Snippets"
],
"type": "module",
"main": "./dist/src/extension.cjs",
Expand Down Expand Up @@ -141,6 +142,12 @@
}
}
}
],
"snippets": [
{
"language": "typespec",
"path": "./snippets.json"
}
]
},
"scripts": {
Expand Down
32 changes: 32 additions & 0 deletions packages/typespec-vscode/snippets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"Enum": {
"prefix": "enum",
"body": "enum ${1:name} {\n ${0:value},\n}",
"description": "Enum definition"
},
"Interface": {
"prefix": "interface",
"body": "interface ${1:name} {\n ${2:member}(${3:parameters}:${4:type}): ${0:returnType};\n}",
"description": "Interface definition"
},
"Model": {
"prefix": "model",
"body": "model ${1:name} {\n ${2:propertyName}: ${0:propertyType};\n}",
"description": "Model definition"
},
"Namespace": {
"prefix": "namespace",
"body": "namespace ${1:name} {\n $TM_SELECTED_TEXT$0\n}",
"description": "Namespace definition"
},
"Operation": {
"prefix": ["op", "operation"],
"body": "op ${1:name}(${2:parameters}:${3:type}): ${0:returnType};",
"description": "Operation definition"
},
"Union": {
"prefix": "union",
"body": "union ${1:name} = ${2:variant1} | ${0:variant2};",
"description": "Named union definition"
}
}
Loading