Skip to content

Commit 8c138b3

Browse files
authored
Merge pull request #4 from JuliaPluto/pg/snippets
2 parents abf3c61 + fe7211b commit 8c138b3

3 files changed

Lines changed: 243 additions & 0 deletions

File tree

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@
9595
}
9696
]
9797
},
98+
"snippets": [
99+
{
100+
"language": "julia",
101+
"path": "./snippets/pluto.json"
102+
},
103+
{
104+
"language": "julia",
105+
"path": "./snippets/dyad-interface.json"
106+
}
107+
],
98108
"commands": [
99109
{
100110
"command": "pluto-notebook.startServer",

snippets/dyad-interface.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"Run Analysis": {
3+
"prefix": "run analysis",
4+
"body": [
5+
"result = ${1:MyAnalysis}()$0"
6+
],
7+
"description": "Run a DyadInterface analysis"
8+
},
9+
"Run Analysis with Begin Block": {
10+
"prefix": "begin analysis",
11+
"body": [
12+
"begin",
13+
"\tresult = ${1:MyAnalysis}()",
14+
"\t${2:plot(result)}",
15+
"end$0"
16+
],
17+
"description": "Run analysis in a begin block"
18+
},
19+
"Get Artifacts": {
20+
"prefix": "artifacts",
21+
"body": [
22+
"artifacts(${1:result}, :${2:RawSolution})$0"
23+
],
24+
"description": "Extract artifacts from analysis result"
25+
},
26+
"Get Artifacts with Begin Block": {
27+
"prefix": "begin artifacts",
28+
"body": [
29+
"begin",
30+
"\tusing DyadInterface: artifacts",
31+
"\tsol = artifacts(${1:result}, :RawSolution)",
32+
"\t${2:sol(1.0)}",
33+
"end$0"
34+
],
35+
"description": "Extract and work with artifacts in a begin block"
36+
},
37+
"Plot Analysis Result": {
38+
"prefix": "plot result",
39+
"body": [
40+
"plot(${1:result})$0"
41+
],
42+
"description": "Plot analysis result"
43+
},
44+
"Import DyadInterface": {
45+
"prefix": "using dyad",
46+
"body": [
47+
"using DyadInterface"
48+
],
49+
"description": "Import DyadInterface package"
50+
}
51+
}

snippets/pluto.json

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
{
2+
"Markdown Cell": {
3+
"prefix": "md",
4+
"body": [
5+
"md\"\"\"",
6+
"${1:# Title}",
7+
"\"\"\"$0"
8+
],
9+
"description": "Create a Pluto markdown cell"
10+
},
11+
"Markdown Cell with Content": {
12+
"prefix": "mdcell",
13+
"body": [
14+
"md\"\"\"",
15+
"# ${1:Section Title}",
16+
"",
17+
"${2:Content}",
18+
"\"\"\""
19+
],
20+
"description": "Create a Pluto markdown cell with title and content"
21+
},
22+
"HTML Cell": {
23+
"prefix": "html",
24+
"body": [
25+
"html\"\"\"",
26+
"${1:<div>Content</div>}",
27+
"\"\"\"$0"
28+
],
29+
"description": "Create a Pluto HTML cell"
30+
},
31+
"PlutoUI Slider": {
32+
"prefix": "slider",
33+
"body": [
34+
"@bind ${1:variable} Slider(${2:1:10}, default=${3:5}, show_value=true)$0"
35+
],
36+
"description": "Create a PlutoUI slider with binding"
37+
},
38+
"PlutoUI NumberField": {
39+
"prefix": "numberfield",
40+
"body": [
41+
"@bind ${1:variable} NumberField(${2:1:100}, default=${3:10})$0"
42+
],
43+
"description": "Create a PlutoUI number field with binding"
44+
},
45+
"PlutoUI TextField": {
46+
"prefix": "textfield",
47+
"body": [
48+
"@bind ${1:variable} TextField(default=\"${2:default text}\")$0"
49+
],
50+
"description": "Create a PlutoUI text field with binding"
51+
},
52+
"PlutoUI CheckBox": {
53+
"prefix": "checkbox",
54+
"body": [
55+
"@bind ${1:variable} CheckBox(default=${2:false})$0"
56+
],
57+
"description": "Create a PlutoUI checkbox with binding"
58+
},
59+
"PlutoUI Select": {
60+
"prefix": "select",
61+
"body": [
62+
"@bind ${1:variable} Select([${2:\"option1\", \"option2\", \"option3\"}])$0"
63+
],
64+
"description": "Create a PlutoUI select dropdown with binding"
65+
},
66+
"PlutoUI Button": {
67+
"prefix": "button",
68+
"body": [
69+
"@bind ${1:variable} Button(\"${2:Click me}\")$0"
70+
],
71+
"description": "Create a PlutoUI button with binding"
72+
},
73+
"Import PlutoUI": {
74+
"prefix": "using plutoui",
75+
"body": [
76+
"using PlutoUI"
77+
],
78+
"description": "Import PlutoUI package"
79+
},
80+
"Import Plots": {
81+
"prefix": "using plots",
82+
"body": [
83+
"using Plots"
84+
],
85+
"description": "Import Plots package"
86+
},
87+
"Import Common Packages": {
88+
"prefix": "using common",
89+
"body": [
90+
"using Markdown",
91+
"using InteractiveUtils"
92+
],
93+
"description": "Import common Pluto packages"
94+
},
95+
"TableOfContents": {
96+
"prefix": "toc",
97+
"body": [
98+
"TableOfContents()"
99+
],
100+
"description": "Add a PlutoUI table of contents"
101+
},
102+
"Begin Block": {
103+
"prefix": "begin",
104+
"body": [
105+
"begin",
106+
"\t${1:# code}",
107+
"end$0"
108+
],
109+
"description": "Create a begin-end block"
110+
},
111+
"Let Block": {
112+
"prefix": "let",
113+
"body": [
114+
"let ${1:x} = ${2:value}",
115+
"\t${3:# code}",
116+
"end$0"
117+
],
118+
"description": "Create a let-end block"
119+
},
120+
"Plot Basic": {
121+
"prefix": "plot",
122+
"body": [
123+
"plot(${1:x}, ${2:y}, ",
124+
"\tlabel=\"${3:label}\",",
125+
"\ttitle=\"${4:title}\",",
126+
"\txlabel=\"${5:x}\",",
127+
"\tylabel=\"${6:y}\"",
128+
")$0"
129+
],
130+
"description": "Create a basic plot"
131+
},
132+
"Scatter Plot": {
133+
"prefix": "scatter",
134+
"body": [
135+
"scatter(${1:x}, ${2:y},",
136+
"\tlabel=\"${3:label}\",",
137+
"\ttitle=\"${4:title}\",",
138+
"\txlabel=\"${5:x}\",",
139+
"\tylabel=\"${6:y}\"",
140+
")$0"
141+
],
142+
"description": "Create a scatter plot"
143+
},
144+
"Heatmap": {
145+
"prefix": "heatmap",
146+
"body": [
147+
"heatmap(${1:data},",
148+
"\ttitle=\"${2:title}\",",
149+
"\txlabel=\"${3:x}\",",
150+
"\tylabel=\"${4:y}\"",
151+
")$0"
152+
],
153+
"description": "Create a heatmap"
154+
},
155+
"Function Definition": {
156+
"prefix": "function",
157+
"body": [
158+
"function ${1:name}(${2:args})",
159+
"\t${3:# body}",
160+
"end$0"
161+
],
162+
"description": "Create a function definition"
163+
},
164+
"Struct Definition": {
165+
"prefix": "struct",
166+
"body": [
167+
"struct ${1:Name}",
168+
"\t${2:field}::${3:Type}",
169+
"end$0"
170+
],
171+
"description": "Create a struct definition"
172+
},
173+
"Mutable Struct": {
174+
"prefix": "mstruct",
175+
"body": [
176+
"mutable struct ${1:Name}",
177+
"\t${2:field}::${3:Type}",
178+
"end$0"
179+
],
180+
"description": "Create a mutable struct definition"
181+
}
182+
}

0 commit comments

Comments
 (0)