Skip to content

Commit 98c2748

Browse files
committed
Add c2 language json
1 parent 572f566 commit 98c2748

File tree

2 files changed

+152
-4
lines changed

2 files changed

+152
-4
lines changed

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,13 +588,17 @@
588588
"language": "loremipsum",
589589
"path": "./snippets/loremipsum.json"
590590
},
591-
{
592-
"language": "cmake",
593-
"path": "./snippets/cmake.json"
594-
},
591+
{
592+
"language": "cmake",
593+
"path": "./snippets/cmake.json"
594+
},
595595
{
596596
"language": "zig",
597597
"path": "./snippets/zig.json"
598+
},
599+
{
600+
"language": "c2",
601+
"path": "./snippets/c2.json"
598602
}
599603
]
600604
}

snippets/c2.json

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
"main": {
3+
"prefix": "main",
4+
"body": [
5+
"public fn i32 main(i32 argc, const char** argv) {",
6+
" ${1:/* code */}",
7+
" return 0;",
8+
"}"
9+
],
10+
"description": "main(..)"
11+
},
12+
"main2": {
13+
"prefix": "mainv",
14+
"body": [
15+
"public fn i32 main() {",
16+
" ${1:/* code */}",
17+
" return 0;",
18+
"}"
19+
],
20+
"description": "main()"
21+
},
22+
"module": {
23+
"prefix": "module",
24+
"body": [
25+
"module ${1:/* module name */};"
26+
],
27+
"description": "module name"
28+
},
29+
"import": {
30+
"prefix": "import",
31+
"body": [
32+
"import ${1:stdio}${2: local};"
33+
],
34+
"description": "import libname"
35+
},
36+
"if": {
37+
"prefix": "if",
38+
"body": [
39+
"if(${1:/* condition */}) {",
40+
" ${0:/* code */}",
41+
"}"
42+
],
43+
"description": "if(..) {..}"
44+
},
45+
"else": {
46+
"prefix": "else",
47+
"body": [
48+
"else {",
49+
" ${0:/* code */}",
50+
"}"
51+
],
52+
"description": "else {..}"
53+
},
54+
"if_else": {
55+
"prefix": "ife",
56+
"body": [
57+
"if(${1:/* condition */}) {",
58+
" ${2:/* code */}",
59+
"} else {",
60+
" ${0:/* code */}",
61+
"}"
62+
],
63+
"description": "if/else"
64+
},
65+
"do_while": {
66+
"prefix": "do",
67+
"body": [
68+
"do {",
69+
" ${2:/* code */}",
70+
"} while(${1:/* condition */});"
71+
],
72+
"description": "do {..} while(..)"
73+
},
74+
"while": {
75+
"prefix": "while",
76+
"body": [
77+
"while(${1:/* condition */}) {",
78+
" ${0:/* code */}",
79+
"}"
80+
],
81+
"description": "while(..) {..}"
82+
},
83+
"for": {
84+
"prefix": "for",
85+
"body": [
86+
"for(${1:u32 i=0}; ${2:i<n}; ${3:++i}) {",
87+
" ${0:/* code */}",
88+
"}"
89+
],
90+
"description": "for(..) {..}"
91+
},
92+
"fn": {
93+
"prefix": "fn",
94+
"body": [
95+
"fn ${1:void} ${2:name}(${3}) {",
96+
" ${0:/* code */}",
97+
"}"
98+
],
99+
"description": "fn {type} {name}(..) {..}"
100+
},
101+
"fn_attribs": {
102+
"prefix": "fna",
103+
"body": [
104+
"fn ${1:void} ${2:name}(${3}) @(${4:noused}) {",
105+
" ${0:/* code */}",
106+
"}"
107+
],
108+
"description": "fn {type} {name}(..) @(..) {..}"
109+
},
110+
"fn_cname": {
111+
"prefix": "fnc",
112+
"body": [
113+
"fn ${1:void} ${2:name}(${3}) @(${4:cname=\"${5:c_func}\"});"
114+
],
115+
"description": "fn {type} {name}(..) @(cname=\"{c_func}\");"
116+
},
117+
"enum": {
118+
"prefix": "enum",
119+
"body": [
120+
"type ${1:/* name */} enum ${2:u32} {",
121+
" ${0:/* fields */}",
122+
"}"
123+
],
124+
"description": "type {name} enum {type} {..}"
125+
},
126+
"struct": {
127+
"prefix": "struct",
128+
"body": [
129+
"type ${1:/* name */} struct {",
130+
" ${0:/* fields */}",
131+
"}"
132+
],
133+
"description": "type {name} struct {..}"
134+
},
135+
"struct_cname": {
136+
"prefix": "structc",
137+
"body": [
138+
"type ${1:/* name */} struct @(${2:crame=\"${3:c_func}\"}${4:, opaque}) {",
139+
" ${0:/* fields */}",
140+
"}"
141+
],
142+
"description": "type {name} struct @(cname=\"{c_func} {opaque}\") {..}"
143+
}
144+
}

0 commit comments

Comments
 (0)