Skip to content

Commit

Permalink
Merge pull request #12311 from CesiumGS/snippets
Browse files Browse the repository at this point in the history
Add snippets for VSCode DX
  • Loading branch information
lukemckinstry authored Nov 15, 2024
2 parents 09a0276 + 993de84 commit 91821cc
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .vscode/cesiumjs.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
// Place your workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Debug Pragma": {
"scope": "javascript",
"prefix": "pragdebug",
"description": "Insert or wrap selection with debug pragma comments",
"body": [
"//>>includeStart('debug', pragmas.debug);",
"${TM_SELECTED_TEXT}$0",
"//>>includeEnd('debug')"
]
},
"Check type": {
"prefix": "check",
"body": [
"Check.typeOf.${2:string}(\"${1:value}\", ${1:value});"
],
"description": "Check Type of a variable"
},
"Check type if defined": {
"prefix": "checkifdef",
"body": [
"if (defined(${1:value})) {",
" Check.typeOf.${2:string}(\"${1:value}\", ${1:value});",
"}"
],
"description": "Check type of a variable if it's defined"
}
}
4 changes: 4 additions & 0 deletions Documentation/Contributors/VSCodeGuide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ restart VSCode after you are done installing extensions.
- **[Shader languages support for VS Code](https://marketplace.visualstudio.com/items?itemName=slevesque.shader)** by slevesque - This extension provides syntax highlighting for CesiumJS's shader code.
- **[glTF Extension for VS Code](https://marketplace.visualstudio.com/items?itemName=cesium.gltf-vscode)** by CesiumJS.org - This extension adds features for previewing and editing 3D models in glTF files.

## Snippets

We have a small (but growing) collection of snippets to make it easier to write code in CesiumJS. For example, `pragdebug` which will expand to the debug pragma we use to strip out code in production builds. These are stored in `.vscode/cesiumjs.code-snippets`. Refer to that file for the full list available and feel free to add to it for common code constructs you find yourself writing.

## VSCode Tasks and Files

You can launch any of CesiumJS's npm tasks from within VSCode by pressing
Expand Down

0 comments on commit 91821cc

Please sign in to comment.