Skip to content

Commit 63e4585

Browse files
committed
Add some basic code snippets
1 parent 3ff361f commit 63e4585

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
"configuration": "./language-configuration.json"
3333
}
3434
],
35+
"snippets": [
36+
{
37+
"language": "scala",
38+
"path": "./snippets/scala.json"
39+
}
40+
],
3541
"grammars": [
3642
{
3743
"language": "scala",

snippets/scala.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
".source.scala": {
3+
"main": {
4+
"prefix": "def main",
5+
"body": "def main(args: Array[String]): Unit = {\n\t${1:expr}\n}",
6+
"description": "Snippet for if expression"
7+
},
8+
"val": {
9+
"prefix": "val",
10+
"body": "val ${1:name}: ${2:Type} = ${3:rhs}",
11+
"description": "Snippet for a val declaration with explicit type"
12+
},
13+
"var": {
14+
"prefix": "var",
15+
"body": "var ${1:name}: ${2:Type} = ${3:rhs}",
16+
"description": "Snippet for a var declaration with explicit type"
17+
},
18+
"lazy val": {
19+
"prefix": "lazy val",
20+
"body": "lazy val ${1:name}: ${2:Type} = ${3:rhs}",
21+
"description": "Snippet for a var declaration with explicit type"
22+
},
23+
"def without arguments": {
24+
"prefix": "def",
25+
"body": "def ${1:name}: ${4:ReturnType} = ${5:rhs}",
26+
"description": "Snippet for a var declaration with explicit type"
27+
},
28+
"def with 1 argument": {
29+
"prefix": "def1",
30+
"body": "def ${1:name}(${2:arg}: ${3:ArgType}): ${4:ReturnType} = ${5:rhs}",
31+
"description": "Snippet for a var declaration with explicit type"
32+
},
33+
"def with 2 arguments": {
34+
"prefix": "def2",
35+
"body": "def ${1:name}(${2:arg1}: ${3:ArgType1}, ${4:arg2}: ${5:ArgType2}): ${6:ReturnType} = ${7:rhs}",
36+
"description": "Snippet for a var declaration with explicit type"
37+
},
38+
"if expression": {
39+
"prefix": "if",
40+
"body": "if (${1:condition}) ${2:thenDo} \nelse ${3:elseDo}",
41+
"description": "Snippet for if expression"
42+
},
43+
"if statement": {
44+
"prefix": "if",
45+
"body": "if (${1:condition}) {\n\t${2:thenDo}\n}",
46+
"description": "Snippet for if statement"
47+
},
48+
"else branch": {
49+
"prefix": "else",
50+
"body": "else {\n\t${0:elseDo}\n}",
51+
"description": "Snippet for else branch"
52+
},
53+
"match": {
54+
"prefix": "match",
55+
"body": "match {\n\tcase ${1:pattern} => $2 \n}",
56+
"description": "Snippet for else branch"
57+
},
58+
"case": {
59+
"prefix": "case",
60+
"body": "case ${1:pattern} => $2",
61+
"description": "Snippet for else branch"
62+
},
63+
"case if": {
64+
"prefix": "case if",
65+
"body": "case ${1:pattern} if ${2:guard} => $3",
66+
"description": "Snippet for else branch"
67+
},
68+
"try catch": {
69+
"prefix": "try catch",
70+
"body": "try {\n\t${1:expression}\n} catch {\n\tcase ex: ${2:ExeptionClass} => $3 \n}",
71+
"description": "Snippet for try/catch expression"
72+
},
73+
"try catch finally": {
74+
"prefix": "try catch finally",
75+
"body": "try {\n\t${1:expression}\n} catch {\n\tcase ex: ${2:ExeptionClass} => $3 \n} finally {\n\t${4:finallyDo}\n}",
76+
"description": "Snippet for try/catch/finally expression"
77+
},
78+
"try finally": {
79+
"prefix": "try finally",
80+
"body": "try {\n\t${1:expression}\n} finally {\n\t${4:finallyDo}\n}",
81+
"description": "Snippet for try/finally expression"
82+
}
83+
}
84+
}

0 commit comments

Comments
 (0)