Skip to content

Commit 72227f5

Browse files
authored
feat(gleam): add gleam snippets rafamadriz#418 (rafamadriz#423)
- Add snippet support for Gleam. The snippets are taken from https://github.com/gleam-lang/vscode-gleam/blob/main/snippets.json - Minor edit in `package.json`
1 parent 1b05cda commit 72227f5

File tree

2 files changed

+236
-1
lines changed

2 files changed

+236
-1
lines changed

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,14 @@
556556
"language": "purescript",
557557
"path": "./snippets/purescript.json"
558558
},
559+
{
560+
"language": "gleam",
561+
"path": "./snippets/gleam.json"
562+
},
559563
{
560564
"language": "asciidoc",
561565
"path": "./snippets/asciidoc.json"
562-
},
566+
}
563567
]
564568
}
565569
}

snippets/gleam.json

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
{
2+
"Public Function": {
3+
"prefix": [
4+
"pub",
5+
"pub fn"
6+
],
7+
"body": [
8+
"pub fn ${1:function_name}(${2}) -> ${3:Nil} {",
9+
"\t${0:todo}",
10+
"}"
11+
],
12+
"description": "public function"
13+
},
14+
"Private Function": {
15+
"prefix": [
16+
"fn"
17+
],
18+
"body": [
19+
"fn ${1:function_name}(${2}) -> ${3:Nil} {",
20+
"\t${0:todo}",
21+
"}"
22+
],
23+
"description": "private function"
24+
},
25+
"Test Function": {
26+
"prefix": [
27+
"test"
28+
],
29+
"body": [
30+
"pub fn ${1:name}_test() {",
31+
"\t${0}",
32+
"}"
33+
],
34+
"description": "test function"
35+
},
36+
"Anonymous Function": {
37+
"prefix": [
38+
"af",
39+
"fn"
40+
],
41+
"body": [
42+
"fn(${1}) { ${0} }"
43+
],
44+
"description": "anonymous function"
45+
},
46+
"Let assignment": {
47+
"prefix": [
48+
"let"
49+
],
50+
"body": [
51+
"let ${1} = ${0}"
52+
],
53+
"description": "let assignment"
54+
},
55+
"Let Assert assignment": {
56+
"prefix": [
57+
"leta"
58+
],
59+
"body": [
60+
"let assert ${1} = ${0}"
61+
],
62+
"description": "let assert assignment"
63+
},
64+
"Use expression": {
65+
"prefix": [
66+
"use"
67+
],
68+
"body": [
69+
"use ${1} <- ${0}"
70+
],
71+
"description": "use expression"
72+
},
73+
"Case Expression": {
74+
"prefix": [
75+
"case"
76+
],
77+
"body": [
78+
"case ${1} {",
79+
"\t${2} -> ${0}",
80+
"}"
81+
],
82+
"description": "case expression"
83+
},
84+
"Type": {
85+
"prefix": [
86+
"type"
87+
],
88+
"body": [
89+
"type ${1:Name} {",
90+
"\t${0:$1}",
91+
"}"
92+
],
93+
"description": "type declaration"
94+
},
95+
"Public Type": {
96+
"prefix": [
97+
"pty",
98+
"pub",
99+
"pub type"
100+
],
101+
"body": [
102+
"pub type ${1:Name} {",
103+
"\t${0:$1}",
104+
"}"
105+
],
106+
"description": "public type declaration"
107+
},
108+
"External attribute": {
109+
"prefix": [
110+
"external"
111+
],
112+
"body": [
113+
"@external(${1:erlang}, \"${2}\", \"${0}\")"
114+
],
115+
"description": "external attribute"
116+
},
117+
"Public External Function": {
118+
"prefix": [
119+
"pexfn",
120+
"pub",
121+
"pub external",
122+
"pub external fn"
123+
],
124+
"body": [
125+
"pub external fn ${1:function_name}(${2}) -> ${3:Nil} = \"${4}\" \"${0}\""
126+
],
127+
"description": "public external function"
128+
},
129+
"Import": {
130+
"prefix": [
131+
"im",
132+
"import"
133+
],
134+
"body": [
135+
"import ${0:gleam/result}"
136+
],
137+
"description": "import"
138+
},
139+
"Import Unqualified": {
140+
"prefix": [
141+
"im.",
142+
"import"
143+
],
144+
"body": [
145+
"import ${1:gleam/result}.{${0}}"
146+
],
147+
"description": "import unqualified"
148+
},
149+
"Pipe": {
150+
"prefix": [
151+
"p",
152+
"|>"
153+
],
154+
"body": [
155+
"|> ${0}"
156+
],
157+
"description": "Pipe |>"
158+
},
159+
"Tuple": {
160+
"prefix": [
161+
"#",
162+
"tuple"
163+
],
164+
"body": [
165+
"#(${0})"
166+
],
167+
"description": "tuple #()"
168+
},
169+
"Block": {
170+
"prefix": [
171+
"bl"
172+
],
173+
"body": [
174+
"{",
175+
"\t${0}",
176+
"}"
177+
],
178+
"description": "block"
179+
},
180+
"Should Equal": {
181+
"prefix": [
182+
"seq",
183+
"should"
184+
],
185+
"body": [
186+
"should.equal(${0})"
187+
],
188+
"description": "should.equal"
189+
},
190+
"Should Be True": {
191+
"prefix": [
192+
"strue",
193+
"should",
194+
"should.b"
195+
],
196+
"body": [
197+
"should.be_true(${0})"
198+
],
199+
"description": "should.be_true"
200+
},
201+
"Should Be False": {
202+
"prefix": [
203+
"sfalse",
204+
"should",
205+
"should.b"
206+
],
207+
"body": [
208+
"should.be_false(${0})"
209+
],
210+
"description": "should.be_false"
211+
},
212+
"Public Constant": {
213+
"prefix": [
214+
"pub",
215+
"pub const"
216+
],
217+
"body": [
218+
"pub const ${1} = ${0}"
219+
],
220+
"description": "public constant"
221+
},
222+
"Constant": {
223+
"prefix": [
224+
"const"
225+
],
226+
"body": [
227+
"const ${1} = ${0}"
228+
],
229+
"description": "constant"
230+
}
231+
}

0 commit comments

Comments
 (0)