Skip to content

Commit

Permalink
[vs-code-extension] add basic snippets for typespec (microsoft#4737)
Browse files Browse the repository at this point in the history
- add snippets for typespec basic constructs
- package snippets within vs code extension

part of microsoft#4559
  • Loading branch information
archerzz authored and swatikumar committed Nov 5, 2024
1 parent 90c2639 commit 2f3e91e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
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"
}
}

0 comments on commit 2f3e91e

Please sign in to comment.