You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[idea] :D2Preview — render the current D2 diagram to an image in-editor #339
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.
Activity