What
d2.vim and tree-sitter-d2 (lua/config/plugins.lua:59-60) give .d2 files syntax highlighting and folding, but there is no way to see the diagram those files describe without leaving Neovim and running the d2 CLI (d2lang/d2) by hand. Editing a diagram language entirely blind defeats much of the point of it.
Where
A new autocmd/command, likely alongside the other config.* extra-tier modules (init.lua:5-20), gated on filetype == "d2". It would shell out via vim.system to d2 <file> /tmp/<name>.png (or .svg) and hand the result to whichever image path the config settles on: snacks.image is already enabled (lua/config/plugin_config.lua:430, image = { enabled = true }), and the custom config.image module is also wired in (init.lua:16, extra tier, min = "0.13") pending the broken-vim.ui.img rewrite tracked in #286/#8.
Why it matters
Three pieces of already-installed, already-configured infrastructure — D2 syntax support, snacks' image rendering, and the custom image viewer — currently have no bridge connecting them for this one filetype. It's a small amount of glue (one vim.system call + an existing image-display path) for a feature that's otherwise completely absent: right now the only way to check a D2 diagram renders correctly is to cd out to a terminal and run d2 manually.
Recommended action
Add a :D2Preview user command (and optionally an autocmd on BufWritePost for .d2 files, debounced) that runs d2 async on the current buffer's file, writes to a temp image, and opens it via snacks.image (or config.image once #286 lands) in a split/float — reusing the async-job and notify patterns already established in lua/config/worktree.lua and lua/config/server.lua.
What
d2.vimandtree-sitter-d2(lua/config/plugins.lua:59-60) give.d2files syntax highlighting and folding, but there is no way to see the diagram those files describe without leaving Neovim and running thed2CLI (d2lang/d2) by hand. Editing a diagram language entirely blind defeats much of the point of it.Where
A new autocmd/command, likely alongside the other
config.*extra-tier modules (init.lua:5-20), gated onfiletype == "d2". It would shell out viavim.systemtod2 <file> /tmp/<name>.png(or.svg) and hand the result to whichever image path the config settles on:snacks.imageis already enabled (lua/config/plugin_config.lua:430,image = { enabled = true }), and the customconfig.imagemodule is also wired in (init.lua:16, extra tier,min = "0.13") pending the broken-vim.ui.imgrewrite tracked in#286/#8.Why it matters
Three pieces of already-installed, already-configured infrastructure — D2 syntax support, snacks' image rendering, and the custom image viewer — currently have no bridge connecting them for this one filetype. It's a small amount of glue (one
vim.systemcall + an existing image-display path) for a feature that's otherwise completely absent: right now the only way to check a D2 diagram renders correctly is tocdout to a terminal and rund2manually.Recommended action
Add a
:D2Previewuser command (and optionally an autocmd onBufWritePostfor.d2files, debounced) that runsd2async on the current buffer's file, writes to a temp image, and opens it viasnacks.image(orconfig.imageonce#286lands) in a split/float — reusing the async-job and notify patterns already established inlua/config/worktree.luaandlua/config/server.lua.