From 21eb520f42d9e3ddd1585d906d9e791f62b0a836 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Sat, 11 Nov 2023 12:48:32 +0100 Subject: [PATCH] feat: VS Code snippets --- packages/safe-ds-vscode/package.json | 8 +- packages/safe-ds-vscode/snippets/safe-ds.json | 82 +++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 packages/safe-ds-vscode/snippets/safe-ds.json diff --git a/packages/safe-ds-vscode/package.json b/packages/safe-ds-vscode/package.json index 483f05656..b508c4d59 100644 --- a/packages/safe-ds-vscode/package.json +++ b/packages/safe-ds-vscode/package.json @@ -86,7 +86,13 @@ "editor.wordSeparators": "`~!@#%^&*()-=+[]{}\\|;:'\",.<>/?»«", "files.trimTrailingWhitespace": true } - } + }, + "snippets": [ + { + "language": "safe-ds", + "path": "./snippets/safe-ds.json" + } + ] }, "type": "module", "main": "dist/extension/mainClient.cjs", diff --git a/packages/safe-ds-vscode/snippets/safe-ds.json b/packages/safe-ds-vscode/snippets/safe-ds.json new file mode 100644 index 000000000..0679b88a7 --- /dev/null +++ b/packages/safe-ds-vscode/snippets/safe-ds.json @@ -0,0 +1,82 @@ +{ + "Import": { + "prefix": ["from", "import"], + "body": ["from $1 import $0"], + "description": "Import of declarations from a package." + }, + "Minimal Annotation": { + "prefix": ["minimal-annotation"], + "body": ["annotation ${0:MyAnnotation}"], + "description": "A minimal annotation." + }, + "Annotation": { + "prefix": ["annotation"], + "body": ["annotation ${1:MyAnnotation}${2:($3)} ${4:where {$0\\}}"], + "description": "An annotation." + }, + "Attribute": { + "prefix": ["attribute"], + "body": ["${1|static |}attr ${2:myAttribute}: $0"], + "description": "An attribute." + }, + "Minimal Class": { + "prefix": ["minimal-class"], + "body": ["class ${0:MyClass}"], + "description": "A minimal class." + }, + "Class": { + "prefix": ["class"], + "body": ["class ${1:MyClass}${2:<$3>}${4:($5)} ${6:sub $7} ${8:where {$9\\}} ${10:{$0\\}}"], + "description": "A class." + }, + "Enum": { + "prefix": ["enumeration"], + "body": ["enum ${1:MyEnum} {", " $0", "}"], + "description": "An enumeration." + }, + "Minimal Function": { + "prefix": ["minimal-function"], + "body": ["fun ${1:myFunction}($0)"], + "description": "A minimal function." + }, + "Function": { + "prefix": ["function", "method"], + "body": ["${1|static |}fun ${2:myFunction}${3:<$4>}($5) ${6:-> ($7)} ${8:where {$0\\}}"], + "description": "A function." + }, + "Schema": { + "prefix": ["schema"], + "body": ["schema ${1:MySchema} {", " $0", "}"], + "description": "A schema." + }, + "Pipeline": { + "prefix": ["pipeline"], + "body": ["pipeline ${1:MyPipeline} {", " $0", "}"], + "description": "A pipeline." + }, + "Segment": { + "prefix": ["segment"], + "body": ["${1|internal ,private |}segment ${2:mySegment}($3) ${4:-> ($5)} {", " $0", "}"], + "description": "A segment." + }, + "Block Lambda": { + "prefix": ["block-lambda"], + "body": ["($1) -> {", " $0", "}"], + "description": "A lambda that executes a list of statements." + }, + "Expression Lambda": { + "prefix": ["expression-lambda"], + "body": ["($1) -> $0"], + "description": "A lambda that returns a single expression." + }, + "Block Comment": { + "prefix": ["block-comment"], + "body": ["/*", " * $0", " */"], + "description": "A block comment." + }, + "Documentation Comment": { + "prefix": ["documentation-comment"], + "body": ["/**", " * $0", " */"], + "description": "A documentation comment." + } +}