Skip to content

BUG: image preview doesn't work #1373

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

Closed
3 tasks done
sinelnikov-web opened this issue Mar 2, 2024 · 7 comments · Fixed by #1648
Closed
3 tasks done

BUG: image preview doesn't work #1373

sinelnikov-web opened this issue Mar 2, 2024 · 7 comments · Fixed by #1648
Labels
bug Something isn't working question Further information is requested

Comments

@sinelnikov-web
Copy link

Did you check docs and existing issues?

  • I have read all the docs.
  • I have searched the existing issues.
  • I have searched the existing discussions.

Neovim Version (nvim -v)

0.9.5

Operating System / Version

MacOS 14.3.1

Describe the Bug

I have the image.nvim dependency installed, and the setting for image_preview is also explicitly specified, but image doesn't render

Screenshots, Traceback

image

Steps to Reproduce

  1. Install neo-tree with image.nvim dependency
  2. Open neo-tree
  3. Open preview of any image

Expected Behavior

Rendered image in preview

Your Configuration

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "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", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
}

local neotree_config = {
  "nvim-neo-tree/neo-tree.nvim",
  dependencies = { "MunifTanjim/nui.nvim", "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim", "3rd/image.nvim" },
  cmd = { "Neotree" },
  opts = {
    window = {
      mappings = {
        ["P"] = { "toggle_preview", config = { use_float = true, use_image_nvim = true } },
      }
    }
  },
}

table.insert(plugins, neotree_config)
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@sinelnikov-web sinelnikov-web added the bug Something isn't working label Mar 2, 2024
@pysan3
Copy link
Collaborator

pysan3 commented Mar 2, 2024

Could you double check if image.nvim itself indeed works but only fails with neo-tree?

https://github.com/3rd/image.nvim#try-it-out-with-a-minimal-setup

@pysan3 pysan3 added the question Further information is requested label Mar 2, 2024
@DamienPetrilli
Copy link

I have the exact same issue on macOS. I did the minimal setup and it works. Yet Neotree previews doesn't :(
Screenshot 2024-08-17 at 11 08 17 AM
Screenshot 2024-08-17 at 11 08 47 AM

@turkus
Copy link

turkus commented Dec 1, 2024

I have:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
and have the same issue.

@besserwisser
Copy link

besserwisser commented Jan 21, 2025

Same with macos 15.2 and kitty 0.39.0. The minimal setup works, but the neo tree integration does not.

-- ~/.config/nvim/lua/plugins/neo-tree.lua
return {
  "nvim-neo-tree/neo-tree.nvim",
  branch = "v3.x",
  dependencies = {
    "nvim-lua/plenary.nvim",
    "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
    "MunifTanjim/nui.nvim",
    "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
  },
}

FYI: Also tried iTerm2 + ueberzugpp first. Because I wasn't sure, if I did miss something, I then tried Kitty.

@besserwisser
Copy link

besserwisser commented Jan 24, 2025

Is it fixed for everyone, when you use the branch = "main", in the config? For me it is broken afterwards.

return {
  "nvim-neo-tree/neo-tree.nvim",
  branch = "main",
  dependencies = {
    "nvim-lua/plenary.nvim",
    "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
    "MunifTanjim/nui.nvim",
    "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information. Doesn't work right now. Wait for this: https://github.com/nvim-neo-tree/neo-tree.nvim/issues/1373
  },
  opts = {
    filesystem = {
      window = {
        mappings = {
          ["o"] = "system_open",
          ["P"] = { "toggle_preview", config = { use_float = true, use_image_nvim = true } },
        },
      },
    },
    commands = {
      system_open = function(state)
        local node = state.tree:get_node()
        local path = node:get_id()
        -- macOs: open file in default application in the background.
        vim.fn.jobstart({ "open", path }, { detach = true })
      end,
    },
  },
}
Image

@pynappo
Copy link
Collaborator

pynappo commented Jan 24, 2025

could you post the full first line of the error?

Is it fixed for everyone, when you use the branch = "main", in the config? For me it is broken afterwards.

It looks like setup() needs to be called on image.nvim. I'll prevent the integration from erroring (my bad) and probably setup image.nvim if it isn't already loaded.

@besserwisser
Copy link

Ah sure, here is the full error log:

E5108: Error executing lua: ...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:280: Error executing lua: ...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:281: Invalid 'group': 'image.nvim'
stack traceback:
	[C]: in function 'nvim_exec_autocmds'
	...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:281: in function <...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:280>
	[C]: in function 'nvim_win_call'
	...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:280: in function 'try_load_image_nvim_buf'
	...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:303: in function 'setBuffer'
	...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:132: in function 'preview'
	...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:399: in function 'show'
	...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:407: in function 'toggle'
	...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:667: in function <...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:666>
stack traceback:
	[C]: in function 'nvim_win_call'
	...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:280: in function 'try_load_image_nvim_buf'
	...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:303: in function 'setBuffer'
	...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:132: in function 'preview'
	...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:399: in function 'show'
	...zy/neo-tree.nvim/lua/neo-tree/sources/common/preview.lua:407: in function 'toggle'
	...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:667: in function <...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:666>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants