Skip to content

Conversation

@MosaicMan
Copy link

Description

Support image viewer when neovim is running within a container. Currently, instances of neovim running docker don't display images properly, even with the "force" flag or SNACKS_ variable enabled.

Docker containers were being treated as "local" sessions because they don't set the standard SSH environment variables. Consequently, snacks.nvim was sending file paths (e.g., /home/user/image.png inside the container) to the terminal running on the host). The host terminal couldn't find this path on its own filesystem, so no image was displayed.

This PR addresses the issue by updating lua/snacks/image/terminal.lua to:

  1. Detect Docker: It now checks for the existence of /.dockerenv or /run/.containerenv to identify if it's running inside a container.
  2. Force Remote Mode: When Docker is detected, it sets the remote = true flag. This forces the image module to transmit the actual image data to the terminal instead of just the file path.
  3. If the reported pixel dimensions are 0 (as is often the case with raw shells inside of Docker), it now falls back to calculating them based on the reported rows/columns and a default font size. This ensures checkhealth (and the image viewer) gets a usable size even in plain Docker environments with no tmux.

Screenshots

Current display within docker:
image

After patch:
image

Support image viewer when neovim is running within a container.
@github-actions github-actions bot added size/m Medium PR (<50 lines changed) image labels Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

image size/m Medium PR (<50 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant