Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images not displayed #7

Closed
stevearc opened this issue Jul 12, 2023 · 3 comments
Closed

Images not displayed #7

stevearc opened this issue Jul 12, 2023 · 3 comments

Comments

@stevearc
Copy link

Hi, super exciting to see some progress on the images-in-vim front! This is something I've been wanting for quite some time now. I installed and tried it out, but no matter what I do I can't seem to get the images to show up.

Screenshot 2023-07-11 at 6 47 40 PM

Some things I've tried:

  • I confirmed that ImageMagick is installed
  • I confirmed that the magick rock is installed and in my rtp
  • I inspected the cropped images in the tmp dir and they appear to be correct, normal pngs
  • I'm using entirely the default options (so, kitty backend)
  • I tried running in bare kitty and also tmux-in-kitty with passthrough on
  • I tried this on MacOS and Linux; got the same behavior on both
  • I confirmed that kitty +kitten icat <image> does show the image in the terminal
  • I tried the nvim --clean -c ":luafile minimal-setup.lua"

I created a minimal repro config file

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- Add luarocks to rtp
local home = vim.loop.os_homedir()
package.path = package.path .. ";" .. home .. "/.luarocks/share/lua/5.1/?/init.lua;"
package.path = package.path .. ";" .. home .. "/.luarocks/share/lua/5.1/?.lua;"

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  { "3rd/image.nvim", opts = {} },
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    config = function()
      require("nvim-treesitter.configs").setup({
        ensure_installed = {
          "markdown",
          "markdown_inline",
        },
      })
    end,
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")

And if I run it with nvim -u repro.lua on the test file

# Hello World

![This is a remote image](https://gist.ro/s/remote.png)

it reproduces the issue. No images.
Any ideas what's going on?

@3rd
Copy link
Owner

3rd commented Jul 12, 2023

Hey, glad you're interested and thanks for the detailed description!
I tried your repro config and it works on my end, the only thing that comes to mind would be maybe the Kitty version?

Could you try the minimal graphics example?

Just make a test.sh file with:

#!/usr/bin/env bash
transmit_png() {
  data=$(base64 "$1")
  data="${data//[[:space:]]/}"
  builtin local pos=0
  builtin local chunk_size=4096
  while [ "$pos" -lt ${#data} ]; do
    builtin printf "\e_G"
    [ "$pos" = "0" ] && printf "a=T,f=100,"
    builtin local chunk="${data:$pos:$chunk_size}"
    pos=$(($pos + $chunk_size))
    [ "$pos" -lt ${#data} ] && builtin printf "m=1"
    [ ${#chunk} -gt 0 ] && builtin printf ";%s" "$chunk"
    builtin printf "\e\\"
  done
}

transmit_png "$1"

And pass an image to it: ./test.sh image.png

Just to rule out Kitty, I think the icat kitten is a bit special, but hopefully test.sh won't work and we could have our answer. I'm on Kitty 0.28.1, which version are you using?

@stevearc
Copy link
Author

The version was the issue! I was on kitty 0.27.1 on Mac, and even older on Linux. I upgraded my packages before this, but I didn't notice that I actually had a local install of an old version in my PATH that prevented it from taking effect >.<

Thanks for the help! If there is a known minimal version of kitty required (0.28?), it might be a good idea to mention it in the requirements section of the README.

I'm really excited to see where this project goes. It's already a massive step up from hologram.nvim!

@3rd
Copy link
Owner

3rd commented Jul 13, 2023

Glad it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants