Skip to content

Document integration images don't render when opening files from nvim-tree or revisiting buffers #347

@charlesg3

Description

@charlesg3

Problem

The document integration in lua/image/utils/document.lua sets up autocmds to detect window/buffer changes and re-render images:

vim.api.nvim_create_autocmd({ "WinNew", "BufWinEnter", "TabEnter" }, {

BufEnter is missing from this list. BufWinEnter only fires the first time a buffer is displayed in a window — it does not fire when revisiting an already-loaded buffer. This means images fail to render in common workflows:

  • Opening a file from nvim-tree: selecting a markdown file from the tree opens it in an adjacent window, but if the buffer was previously loaded, only BufEnter fires (not BufWinEnter), so images don't render
  • Switching buffers: :bnext, :bprev, or buffer pickers switching to a previously-visited buffer only fire BufEnter

Steps to reproduce

  1. Open a markdown file with images via a document integration (e.g. diagram.nvim)
  2. Navigate away (e.g. open another file, or focus nvim-tree)
  3. Return to the markdown buffer via nvim-tree, :bnext, or a buffer picker
  4. Images don't render until another trigger fires (e.g. :e to reload)

Expected behavior

Images should re-render whenever a buffer with a document integration becomes active, regardless of whether it was previously loaded.

Suggested fix

Add "BufEnter" to the autocmd event list. BufEnter fires every time a buffer becomes active in a window, complementing BufWinEnter (first display only), WinNew, and TabEnter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions