{"id":13928908,"url":"https://github.com/terrastruct/d2-vscode","last_synced_at":"2025-04-12T15:35:08.013Z","repository":{"id":63690427,"uuid":"553116959","full_name":"terrastruct/d2-vscode","owner":"terrastruct","description":"VSCode extension for D2 files.","archived":false,"fork":false,"pushed_at":"2024-12-29T17:04:01.000Z","size":5503,"stargazers_count":270,"open_issues_count":26,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-11T15:15:23.018Z","etag":null,"topics":["diagram","diagramming","diagrams"],"latest_commit_sha":null,"homepage":"https://d2lang.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terrastruct.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-17T18:37:43.000Z","updated_at":"2025-04-10T00:11:21.000Z","dependencies_parsed_at":"2024-04-26T04:32:01.681Z","dependency_job_id":"d6f19936-0b69-45d4-bf9e-8576e390659b","html_url":"https://github.com/terrastruct/d2-vscode","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terrastruct%2Fd2-vscode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terrastruct%2Fd2-vscode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terrastruct%2Fd2-vscode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terrastruct%2Fd2-vscode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terrastruct","download_url":"https://codeload.github.com/terrastruct/d2-vscode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248590086,"owners_count":21129747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diagram","diagramming","diagrams"],"created_at":"2024-08-07T18:01:59.190Z","updated_at":"2025-04-12T15:35:07.979Z","avatar_url":"https://github.com/terrastruct.png","language":"TypeScript","funding_links":[],"categories":["others","TypeScript"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cbr /\u003e\n  \u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/terrastruct/d2-vscode/master/docs/assets/header.png\" alt=\"D2\" /\u003e\n  \u003c/div\u003e\n  \u003cbr /\u003e\n\u003c/div\u003e\n\n[![ci](https://github.com/terrastruct/d2-vscode/actions/workflows/ci.yml/badge.svg)](https://github.com/terrastruct/d2-vscode/actions/workflows/ci.yml)\n[![daily](https://github.com/terrastruct/d2-vscode/actions/workflows/daily.yml/badge.svg)](https://github.com/terrastruct/d2-vscode/actions/workflows/daily.yml)\n[![license](https://img.shields.io/github/license/terrastruct/d2-vscode?color=9cf)](./LICENSE)\n\n# VSCode extension for [D2](https://d2lang.com) files.\n\n_Note: Requires D2 to be installed on your machine. See\n[https://github.com/terrastruct/d2/tree/master#install](https://github.com/terrastruct/d2/tree/master#install)\nfor instructions._\n\n## Currently Supports\n\n- Syntax highlighting `.d2` files\n- Open preview window on the side (right-click or (ctrl+shift+d) (mac -\u003e shift+cmd+d))\n- Format Document for `.d2` files\n- View rendered D2 code snippets in markdown document preview\n- Theme and Layout are configurable from settings and the Command Palette\n\n```d2\nx -\u003e y\n\n# d2-vscode can syntax highlight nested markdown correctly.\ny: |`md\n  # d2-vscode\n  VSCode extension for [D2](https://d2lang.com) files.\n`|\n```\n\n## Example\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://terrastruct-site-assets.s3.us-west-1.amazonaws.com/gifs/d2_vscode.gif\" alt=\"D2\" /\u003e\n\u003c/div\u003e\n\n## Install\n\nYou can install using the extension sidebar or by going to the [Visual Studio Marketplace Website](https://marketplace.visualstudio.com/items?itemName=terrastruct.d2) and clicking \"Install\".\n\n## Contributing\n\nTo package and install the extension locally, run:\n\n```sh\nnpm install -g @vscode/vsce\nnpm run dev\n```\n\nYou can run rerun `npm run dev` after any change to install the updated extension.\n\nSometimes VS Code will not pick up the new extension without being restarted so you\ncan also run the following on macOS:\n\n```sh\n# Where d2-testing is some folder in which you want to test the extension.\nosascript -e 'quit app \"Visual Studio Code\"'; yarn dev \u0026\u0026 code ~/d2-testing\n```\n\n### CI\n\nCI relies on Terrastruct's shared [CI submodule](https://github.com/terrastruct/ci).\n\nTo run all CI: `./make.sh`.\n\nTo run individual jobs:\n\n- Format: `./make.sh fmt`\n- Lint: `./make.sh lint`\n- Build: `./make.sh build`\n\nJobs only run on changed files. To force it to run on all files, add `CI_FORCE=1`. This is\nwhat daily job does.\n\n```\nCI_FORCE=1 ./make.sh fmt\n```\n\n### Packaging\n\n```sh\nvsce package\n```\n\nUpload the output `.vsix` onto\n[https://marketplace.visualstudio.com/manage/publishers/terrastruct](https://marketplace.visualstudio.com/manage/publishers/terrastruct).\n\n### launch.json\n\nWe have a `.vscode/launch.json` that enables starting a separate debug VS Code with the\nextension installed without affecting your existing VS Code instance. To use, open\n`d2-vscode` with VS Code and hit `F5`. Press `CMD+R` after making changes to restart the\ndebug VS Code with the updated extension.\n\n### Generating tmLanguage.json\n\nTo regenerate `d2.tmLanguage.json` after updating `d2.tmLanguage.yaml`, use [yq](https://github.com/mikefarah/yq/#install):\n\n```sh\nbrew install yq\nnpm run gen\n```\n\nnote: `npm run dev` will regenerate for you.\n\n### Debugging Keybind\n\nHighly recommend the following keybind for inspecting the textmate scopes under the cursor.\n\n```json\n{\n  \"key\": \"cmd+i\",\n  \"command\": \"editor.action.inspectTMScopes\"\n}\n```\n\n### Offline Distribution\n\nSee https://code.visualstudio.com/docs/editor/extension-marketplace#_install-from-a-vsix\n\n```sh\nnpm install -g @vscode/vsce\nnpm run pkg\n# To install:\n# code --install-extension d2.vsix\n# To uninstall:\n# code --uninstall-extension terrastruct.d2\n```\n\n### markdown.tmLanguage.json\n\nSyntax file used for markdown embedded within d2 block strings.\n\n1. Copied from VS Code's markdown-basics extension.\n2. Renamed to `markdown.d2` and scope to `text.html.markdown.d2`\n3. Then with vim:\n   ```\n   %s/\\(?:\\)\\?\\^|\\\\\\\\G/\\1(?!.*`\\\\\\\\|)(?:\\^|\\\\\\\\G)/g\n   ```\n\n- This replacement ensures the markdown syntax never matches on block string\n  terminators.\n\n4. Then with sed:\n   ```sh\n   gsed -i -E 's/\\[ \\]\\{[^}]*?\\}/\\\\\\\\s*/' markdown.tmLanguage.json\n   ```\n\n- This replacement ensures that the markdown syntax doesn't consider leading spaces to be\n  the beginning of an indented code block as in d2, block strings are indented for\n  readability without the indentation being part of the string contents.\n\n5. Now delete the `list` from `#block`. Lists for some reason eat the block string\n   terminator. e.g. with them enabled the following syntax after the terminating `|`\n   will remain markdown:\n\n   ```d2\n   my shape: |md\n     1. first\n   |\n\n   should be d2 but VS Code highlights as markdown.\n   ```\n\n6. Add `fenced_code_block_d2` based on `fenced_code_block_css` to allow embedding markdown\n   with d2 within d2.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterrastruct%2Fd2-vscode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterrastruct%2Fd2-vscode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterrastruct%2Fd2-vscode/lists"}