diff --git a/package.json b/package.json index d8304a5..d5d5f2d 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "vscode": "^1.63.0" }, "categories": [ - "Programming Languages" + "Programming Languages", + "Snippets" ], "preview": true, "contributes": { @@ -36,6 +37,16 @@ "scopeName": "source.pi", "path": "./syntaxes/pinc.tmLanguage.json" } + ], + "snippets": [ + { + "language": "pinc", + "path": "./snippets/main.json" + }, + { + "language": "pinc", + "path": "./snippets/control-flow.json" + } ] }, "scripts": { diff --git a/snippets/control-flow.json b/snippets/control-flow.json new file mode 100644 index 0000000..700e044 --- /dev/null +++ b/snippets/control-flow.json @@ -0,0 +1,20 @@ +{ + "For Loop": { + "scope": "pinc", + "prefix": ["for"], + "body": [ + "for (${1:${2:index}, }${3:element} in ${4:array}) {", + "\t$0", + "}" + ] + }, + "If Condition": { + "scope": "pinc", + "prefix": ["if"], + "body": [ + "if (${1:condition}) {", + "\t$0", + "}" + ] + } +} diff --git a/snippets/main.json b/snippets/main.json new file mode 100644 index 0000000..a1e21c3 --- /dev/null +++ b/snippets/main.json @@ -0,0 +1,49 @@ +{ + "Component": { + "scope": "pinc", + "prefix": ["component"], + "body": [ + "component ${1:NewComponent}${2:(${3:label: \"${4:New Component}\"})} {", + "\t${5:use Base;\n}", + "\t$0", + "}" + ] + }, + "Page": { + "scope": "pinc", + "prefix": ["page"], + "body": [ + "page ${1:NewPage}${2:(${3:label: \"${4:New Page}\"})} {", + "\t${5:use Base;\n}", + "\t<>", + "\t\t", + "\t\t", + "\t\t\t${7:\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t$8\n\t\t\t}", + "\t\t\t", + "\t\t\t\t$0", + "\t\t\t", + "\t\t", + "\t", + "}" + ] + }, + "Store": { + "scope": "pinc", + "prefix": ["store"], + "body": [ + "store ${1:NewStore}(single: ${2|false,true|}) {", + "\t$0", + "}" + ] + }, + "Library": { + "scope": "pinc", + "prefix": ["library"], + "body": [ + "library ${1:NewLibrary} {", + "\t${2:use ${3:SubLibrary} = ${4:MyLibrary__Sub}; // Re-Export ${4:MyLibrary__Sub} as ${1:NewLibrary}.${3:SubLibrary}\n}", + "\t$0", + "}" + ] + } +}