├── LICENSE ├── README.md ├── d2.json └── package.json /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Paracelsus-Rose 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # D2 Language Code Snippets 2 | 3 | **D2 Language Code Snippets** is a collection of code snippets for the D2 language, that can be used in any text editor that supports the use of snippets. 4 | 5 | ## ✨ Features 6 | 7 | - 🔨 Create various shapes, including rectangles, squares, parallelograms, cylinders, queues, packages, steps, callouts, stored data, persons, diamonds, ovals, circles, hexagons, and clouds. 8 | - 🎨 Style your shapes and connections with properties such as opacity, stroke, fill, stroke-width, stroke-dash, border-radius, shadow, 3D, multiple, font-size, font-color, animated, bold, italic, and underline. 9 | - 📐 Create diagrams with various arrowhead styles, including triangle, diamond, circle, cf-one, cf-one-required, cf-many, and cf-many-required. 10 | - 💎 Additional filled variants for diamond and circle arrowheads. 11 | 12 | ## ⚡️ Requirements 13 | 14 | - A text editor that supports the use of code snippets. 15 | - Basic knowledge of the D2 language. 16 | 17 | ## 🚀 Installation 18 | 19 | To use these code snippets, you will need to import them into your text editor's snippet library. The process for doing this will vary depending on the text editor you are using. Please consult your text editor's documentation for instructions on how to import code snippets. 20 | 21 | ## 🔨 Usage 22 | 23 | Once you have imported the code snippets into your text editor, you can use them by typing the prefix of the snippet you want to use and then pressing the tab key. The snippet will be inserted into your code, and you can then fill in the placeholders with your own code. 24 | 25 | ## 🙏 Acknowledgments 26 | I would like to thank the D2 language community for their innovative and extremely useful language. It has fully changed my workflow. 27 | 28 | ## 🔗 Resources 29 | [D2 Language Documentation](https://d2lang.com/tour/intro/) 30 | [D2 Github](https://github.com/terrastruct/d2) 31 | [D2 Playground](https://play.d2lang.com/?script=qlDQtVOo5AIEAAD__w%3D%3D&) 32 | 33 | ## License 34 | D2 Language Code Snippets is open-source software licensed under the MIT License. 35 | -------------------------------------------------------------------------------- /d2.json: -------------------------------------------------------------------------------- 1 | { 2 | "rectangle": { 3 | "prefix": "rectangle", 4 | "body": [ 5 | "${1:className}: \"${2:Class Title}\" {", 6 | "\tshape: rectangle", 7 | "", 8 | "\t${3:data}", 9 | "}" 10 | ], 11 | "description": "Inserts a Rectangle Shape for D2" 12 | }, 13 | "square": { 14 | "prefix": "square", 15 | "body": [ 16 | "${1:className}: \"${2:Class Title}\" {", 17 | "\tshape: square", 18 | "", 19 | "\t${3:data}", 20 | "}" 21 | ], 22 | "description": "Inserts a Square Shape for D2" 23 | }, 24 | "page": { 25 | "prefix": "page", 26 | "body": [ 27 | "${1:className}: \"${2:Class Title}\" {", 28 | "\tshape: page", 29 | "", 30 | "\t${3:data}", 31 | "}" 32 | ], 33 | "description": "Inserts a Page Shape for D2" 34 | }, 35 | "parallelogram": { 36 | "prefix": "parallelogram", 37 | "body": [ 38 | "${1:className}: \"${2:Class Title}\" {", 39 | "\tshape: parallelogram", 40 | "", 41 | "\t${3:data}", 42 | "}" 43 | ], 44 | "description": "Inserts a Parallelogram Shape for D2" 45 | }, 46 | "document": { 47 | "prefix": "document", 48 | "body": [ 49 | "${1:className}: \"${2:Class Title}\" {", 50 | "\tshape: document", 51 | "", 52 | "\t${3:data}", 53 | "}" 54 | ], 55 | "description": "Inserts a Document Shape for D2" 56 | }, 57 | "cylinder": { 58 | "prefix": "cylinder", 59 | "body": [ 60 | "${1:className}: \"${2:Class Title}\" {", 61 | "\tshape: cylinder", 62 | "", 63 | "\t${3:data}", 64 | "}" 65 | ], 66 | "description": "Inserts a Cylinder Shape for D2" 67 | }, 68 | "queue": { 69 | "prefix": "queue", 70 | "body": [ 71 | "${1:className}: \"${2:Class Title}\" {", 72 | "\tshape: queue", 73 | "", 74 | "\t${3:data}", 75 | "}" 76 | ], 77 | "description": "Inserts a Queue Shape for D2" 78 | }, 79 | "package": { 80 | "prefix": "package", 81 | "body": [ 82 | "${1:className}: \"${2:Class Title}\" {", 83 | "\tshape: package", 84 | "", 85 | "\t${3:data}", 86 | "}" 87 | ], 88 | "description": "Inserts a Package Shape for D2" 89 | }, 90 | "step": { 91 | "prefix": "step", 92 | "body": [ 93 | "${1:className}: \"${2:Class Title}\" {", 94 | "\tshape: step", 95 | "", 96 | "\t${3:data}", 97 | "}" 98 | ], 99 | "description": "Inserts a Step Shape for D2" 100 | }, 101 | "callout": { 102 | "prefix": "callout", 103 | "body": [ 104 | "${1:className}: \"${2:Class Title}\" {", 105 | "\tshape: callout", 106 | "", 107 | "\t${3:data}", 108 | "}" 109 | ], 110 | "description": "Inserts a Callout Shape for D2" 111 | }, 112 | "stored_data": { 113 | "prefix": "stored_data", 114 | "body": [ 115 | "${1:className}: \"${2:Class Title}\" {", 116 | "\tshape: stored_data", 117 | "", 118 | "\t${3:data}", 119 | "}" 120 | ], 121 | "description": "Inserts a Stored Data Shape for D2" 122 | }, 123 | "person": { 124 | "prefix": "person", 125 | "body": [ 126 | "${1:className}: \"${2:Class Title}\" {", 127 | "\tshape: person", 128 | "", 129 | "\t${3:data}", 130 | "}" 131 | ], 132 | "description": "Inserts a Person Shape for D2" 133 | }, 134 | "diamond": { 135 | "prefix": "diamond", 136 | "body": [ 137 | "${1:className}: \"${2:Class Title}\" {", 138 | "\tshape: diamond", 139 | "", 140 | "\t${3:data}", 141 | "}" 142 | ], 143 | "description": "Inserts a diamond Shape for D2" 144 | }, 145 | "oval": { 146 | "prefix": "oval", 147 | "body": [ 148 | "${1:className}: \"${2:Class Title}\" {", 149 | "\tshape: oval", 150 | "", 151 | "\t${3:data}", 152 | "}" 153 | ], 154 | "description": "Inserts an Oval Shape for D2" 155 | }, 156 | "circle": { 157 | "prefix": "circle", 158 | "body": [ 159 | "${1:className}: \"${2:Class Title}\" {", 160 | "\tshape: circle", 161 | "", 162 | "\t${3:data}", 163 | "}" 164 | ], 165 | "description": "Inserts a Circle Shape for D2" 166 | }, 167 | "hexagon": { 168 | "prefix": "hexagon", 169 | "body": [ 170 | "${1:className}: \"${2:Class Title}\" {", 171 | "\tshape: hexagon", 172 | "", 173 | "\t${3:data}", 174 | "}" 175 | ], 176 | "description": "Inserts a Hexagon Shape for D2" 177 | }, 178 | "cloud": { 179 | "prefix": "cloud", 180 | "body": [ 181 | "${1:className}: \"${2:Class Title}\" {", 182 | "\tshape: cloud", 183 | "", 184 | "\t${3:data}", 185 | "}" 186 | ], 187 | "description": "Inserts a Cloud Shape for D2" 188 | }, 189 | "text": { 190 | "prefix": "text", 191 | "body": [ 192 | "${1:className}: \"${2:Class Title}\" {", 193 | "\tshape: text", 194 | "", 195 | "\t${3:data}", 196 | "}" 197 | ], 198 | "description": "Inserts a Text Shape for D2" 199 | }, 200 | "code": { 201 | "prefix": "code", 202 | "body": [ 203 | "${1:className}: \"${2:Class Title}\" {", 204 | "\tshape: code", 205 | "", 206 | "\t${3:data}", 207 | "}" 208 | ], 209 | "description": "Inserts a Code Shape for D2" 210 | }, 211 | "class": { 212 | "prefix": "class", 213 | "body": [ 214 | "${1:className}: \"${2:Class Title}\" {", 215 | "\tshape: class", 216 | "", 217 | "\t${3:data}", 218 | "}" 219 | ], 220 | "description": "Inserts a Class Shape for D2" 221 | }, 222 | "sql_table": { 223 | "prefix": "sql_table", 224 | "body": [ 225 | "${1:className}: \"${2:Class Title}\" {", 226 | "\tshape: sql_table", 227 | "", 228 | "\t${3:data}", 229 | "}" 230 | ], 231 | "description": "Inserts an SQL Table Shape for D2" 232 | }, 233 | "sequence_diagram": { 234 | "prefix": "sequence_diagram", 235 | "body": [ 236 | "${1:className}: \"${2:Class Title}\" {", 237 | "\tshape: sequence_diagram", 238 | "", 239 | "\t${3:data}", 240 | "}" 241 | ], 242 | "description": "Inserts a Sequence Diagram Shape for D2" 243 | }, 244 | "image": { 245 | "prefix": "image", 246 | "body": [ 247 | "${1:className}: \"${2:Class Title}\" {", 248 | "\tshape: image", 249 | "\ticon: ${3:iconLink}", 250 | "}" 251 | ], 252 | "description": "Inserts an Image Shape for D2" 253 | }, 254 | "style": { 255 | "prefix": "style", 256 | "body": [ 257 | "\tstyle: {", 258 | "\t\t# opacity: 0.4,\t\t#", 259 | "\t\t# stroke: \"#f4a261\", #", 260 | "\t\t# fill: \"#f4a261\",\t # (shape only)", 261 | "\t\t# stroke-width: 1,\t #", 262 | "\t\t# stroke-dash: 5,\t #", 263 | "\t\t# border-radius: 3,\t# (shape only)", 264 | "\t\t# shadow: false,\t # (shape only)", 265 | "\t\t# 3D: false,\t\t # (rectangle/square only)", 266 | "\t\t# multiple: false,\t # (shape only)", 267 | "\t\t# font-size: 28,\t #", 268 | "\t\t# font-color: red,\t #", 269 | "\t\t# animated: false,\t # (connection only)", 270 | "\t\t# bold: false,\t\t #", 271 | "\t\t# italic: false,\t #", 272 | "\t\t# underline: false\t #", 273 | "\t}", 274 | "" 275 | ], 276 | "description": "Inserts a Style with All Default Values" 277 | }, 278 | "Arrow Arrowhead": { 279 | "prefix": "ararrow", 280 | "body": [ 281 | "source-arrowhead: {", 282 | "\tshape: arrow", 283 | "}", 284 | "target-arrowhead: {", 285 | "\t shape: arrow", 286 | "}" 287 | ], 288 | "description": "Inserts an Arrow Arrowhead" 289 | }, 290 | "Diamond Arrowhead": { 291 | "prefix": "ardiamond", 292 | "body": [ 293 | "source-arrowhead: {", 294 | "\tshape: diamond", 295 | "}", 296 | "target-arrowhead: {", 297 | "\t shape: diamond", 298 | "}" 299 | ], 300 | "description": "Inserts a Diamond Arrowhead" 301 | }, 302 | "Circle Arrowhead": { 303 | "prefix": "arcircle", 304 | "body": [ 305 | "source-arrowhead: {", 306 | "\tshape: circle", 307 | "}", 308 | "target-arrowhead: {", 309 | "\t shape: circle", 310 | "}" 311 | ], 312 | "description": "Inserts a Circle Arrowhead" 313 | }, 314 | "Crows Foot One Arrowhead": { 315 | "prefix": "arcfone", 316 | "body": [ 317 | "source-arrowhead: {", 318 | "\tshape: cf-one", 319 | "}", 320 | "target-arrowhead: {", 321 | "\t shape: cf-one", 322 | "}" 323 | ], 324 | "description": "Inserts a Crows Foot One Arrowhead" 325 | }, 326 | "Crows Foot One Required Arrowhead": { 327 | "prefix": "arcfonereq", 328 | "body": [ 329 | "source-arrowhead: {", 330 | "\tshape: cf-one-required", 331 | "}", 332 | "target-arrowhead: {", 333 | "\t shape: cf-one-required", 334 | "}" 335 | ], 336 | "description": "Inserts a Crows Foot One Required Arrowhead" 337 | }, 338 | "Crows Foot Many Arrowhead": { 339 | "prefix": "arcfmany", 340 | "body": [ 341 | "source-arrowhead: {", 342 | "\tshape: cf-many", 343 | "}", 344 | "target-arrowhead: {", 345 | "\t shape: cf-many", 346 | "}" 347 | ], 348 | "description": "Inserts a Crows Foot Many Arrowhead" 349 | }, 350 | "Crows Foot Many Required Arrowhead": { 351 | "prefix": "arcfmanyreq", 352 | "body": [ 353 | "source-arrowhead: {", 354 | "\tshape: cf-many-required", 355 | "}", 356 | "target-arrowhead: {", 357 | "\t shape: cf-many-required", 358 | "}" 359 | ], 360 | "description": "Inserts a Crows Foot Many Required Arrowhead" 361 | }, 362 | "Filled Diamond Arrowhead": { 363 | "prefix": "ardiamondfill", 364 | "body": [ 365 | "source-arrowhead: {", 366 | "\tshape: diamond", 367 | "\tstyle.filled: true", 368 | "}", 369 | "target-arrowhead: {", 370 | "\tshape: diamond", 371 | "\tstyle.filled: true", 372 | "}" 373 | ], 374 | "description": "Inserts a Filled Diamond Arrowhead" 375 | }, 376 | "Filled Circle Arrowhead": { 377 | "prefix": "arcirclefill", 378 | "body": [ 379 | "source-arrowhead: {", 380 | "\tshape: circle", 381 | "\tstyle.filled: true", 382 | "}", 383 | "target-arrowhead: {", 384 | "\tshape: circle", 385 | "\tstyle.filled: true", 386 | "}" 387 | ], 388 | "description": "Inserts a Filled Circle Arrowhead" 389 | } 390 | } 391 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "d2-snippets", 3 | "displayName": "D2 Language Code Snippets", 4 | "description": "A collection of code snippets for the D2 language", 5 | "version": "1.0.0", 6 | "publisher": "Paracelsus-Rose", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/Paracelsus-Rose/D2-Language-Code-Snippets" 10 | }, 11 | "categories": [ 12 | "Snippets" 13 | ], 14 | "contributes": { 15 | "snippets": [ 16 | { 17 | "language": "d2", 18 | "path": "./d2.json" 19 | } 20 | ] 21 | } 22 | } 23 | --------------------------------------------------------------------------------