3rd / image.nvim

🖼️ Bringing images to Neovim.
MIT License
974 stars 38 forks source link

no field package.preload['image/backends/ueberzugpp'] #214

Closed liketoeatcheese closed 2 weeks ago

liketoeatcheese commented 2 weeks ago

Hi, thanks for your great work on this plugin.

I'm having trouble setting this up on nixos in WSL and wezterm. I got the image to work on the terminal. And wants to set it up in neovim. Here's my attempt:

  home.packages = with pkgs; [
     imagemagick ...
 ];
  programs.neovim = {
    enable = true;
    extraLuaPackages = ps: [ ps.magick ];
  };

Here's my config. This works for my home station with kitty, but can't seems to get it to work with ueberzugpp:

if vim.fn.has("wsl") == 1 then
  return {
    "3rd/image.nvim",
    event = "VeryLazy",
    dependencies = {

      { "luarocks.nvim" },
      {
        "nvim-treesitter/nvim-treesitter",
        build = ":TSUpdate",
        config = function()
          require("nvim-treesitter.configs").setup({
            ensure_installed = { "markdown", "pandoc" },
            highlight = { enable = true },
          })
        end,
      },
    },
    opts = {
      backend = "ueberzugpp",
      integrations = {
        markdown = {
          enabled = true,
          clear_in_insert_mode = false,
          download_remote_images = true,
          only_render_image_at_cursor = false,
          filetypes = { "markdown", "vimwiki", "pandoc" }, -- markdown extensions (ie. quarto) can go here
        },
        neorg = {
          enabled = true,
          clear_in_insert_mode = false,
          download_remote_images = true,
          only_render_image_at_cursor = false,
          filetypes = { "norg" },
        },
      },
      max_width = nil,
      max_height = nil,
      max_width_window_percentage = nil,
      max_height_window_percentage = 50,
      tmux_show_only_in_active_window = true,
    },
  }
else
  return {
    "3rd/image.nvim",
    event = "VeryLazy",
    dependencies = {

      { "luarocks.nvim" },
      {
        "nvim-treesitter/nvim-treesitter",
        build = ":TSUpdate",
        config = function()
          require("nvim-treesitter.configs").setup({
            ensure_installed = { "markdown", "pandoc" },
            highlight = { enable = true },
          })
        end,
      },
    },
    opts = {
      backend = "kitty",
      integrations = {
        markdown = {
          enabled = true,
          clear_in_insert_mode = false,
          download_remote_images = true,
          only_render_image_at_cursor = false,
          filetypes = { "markdown", "vimwiki", "pandoc" }, -- markdown extensions (ie. quarto) can go here
        },
        neorg = {
          enabled = true,
          clear_in_insert_mode = false,
          download_remote_images = true,
          only_render_image_at_cursor = false,
          filetypes = { "norg" },
        },
      },
      max_width = nil,
      max_height = nil,
      max_width_window_percentage = nil,
      max_height_window_percentage = 50,
      tmux_show_only_in_active_window = true,
      kitty_method = "normal",
    },
  }
end
Failed to run `config` for image.nvim

...ham/.local/share/nvim/lazy/image.nvim/lua/image/init.lua:71: module 'image/backends/ueberzugpp' not found:
^Ino field package.preload['image/backends/ueberzugpp']
cache_loader: module image/backends/ueberzugpp not found
cache_loader_lib: module image/backends/ueberzugpp not found
^Ino file '/nix/store/w6bjra0szhz64hcph19l6rx7zl6pwsi4-luajit-2.1.1713773202-env/share/lua/5.1/image/backends/ueberzugpp.lua'
^Ino file '/nix/store/w6bjra0szhz64hcph19l6rx7zl6pwsi4-luajit-2.1.1713773202-env/share/lua/5.1/image/backends/ueberzugpp/init.lua'
^Ino file '/nix/store/9bh5gq3d76vm6kypl91pixk6dnz98w3n-luajit2.1-magick-1.6.0-1/share/lua/5.1/image/backends/ueberzugpp.lua'
^Ino file '/nix/store/9bh5gq3d76vm6kypl91pixk6dnz98w3n-luajit2.1-magick-1.6.0-1/share/lua/5.1/image/backends/ueberzugpp/init.lua'
^Ino file '/home/wpham/.luarocks/share/lua/5.1/image/backends/ueberzugpp/init.lua'
^Ino file '/home/wpham/.luarocks/share/lua/5.1/image/backends/ueberzugpp.lua'
^Ino file '/home/wpham/.local/share/nvim/lazy/luarocks.nvim/.rocks/share/lua/5.1/image/backends/ueberzugpp.lua'
^Ino file '/home/wpham/.local/share/nvim/lazy/luarocks.nvim/.rocks/share/lua/5.1/image/backends/ueberzugpp/init.lua'
^Ino file '/home/wpham/.local/share/nvim/lazy/luarocks.nvim/.rocks/lua/image/backends/ueberzugpp.lua'
^Ino file '/home/wpham/.local/share/nvim/lazy/luarocks.nvim/.rocks/lua/image/backends/ueberzugpp/init.lua'
^Ino file '/home/wpham/.local/share/nvim/lazy-rocks/telescope.nvim/share/lua/5.1/image/backends/ueberzugpp.lua'
^Ino file '/home/wpham/.local/share/nvim/lazy-rocks/telescope.nvim/share/lua/5.1/image/backends/ueberzugpp/init.lua'
^Ino file '/nix/store/w6bjra0szhz64hcph19l6rx7zl6pwsi4-luajit-2.1.1713773202-env/lib/lua/5.1/image/backends/ueberzugpp.so'
^Ino file '/nix/store/9bh5gq3d76vm6kypl91pixk6dnz98w3n-luajit2.1-magick-1.6.0-1/lib/lua/5.1/image/backends/ueberzugpp.so'
^Ino file '/home/wpham/.local/share/nvim/lazy/luarocks.nvim/.rocks/lib/lua/5.1/image/backends/ueberzugpp.so'
^Ino file '/home/wpham/.local/share/nvim/lazy-rocks/telescope.nvim/lib/lua/5.1/image/backends/ueberzugpp.so'

# stacktrace:
  - /image.nvim/lua/image/init.lua:71 _in_ **setup**

Any thoughts?

3rd commented 2 weeks ago

Yes, it's just "ueberzug"

liketoeatcheese commented 2 weeks ago

Sweet! That stoped the error. But I can't seem to view the image. I tried to view images in yazi which confirms that it seems to work in the terminal. Is there any way to debug this? image

3rd commented 2 weeks ago

Sweet! That stoped the error. But I can't seem to view the image. I tried to view images in yazi which confirms that it seems to work in the terminal. Is there any way to debug this? image

Are you sure yazi is using ueberzug?

liketoeatcheese commented 2 weeks ago

🖼️ Built-in Support for Multiple Image Protocols: Also integrated with Überzug++ and Chafa, covering almost all terminals.

https://github.com/sxyazi/yazi/pull/1066

Based on my understanding, yes.

I also managed to run ueberzugpp in standalone mode with: ueberzugpp layer --use-escape-codes Enter to go into ueberzugpp, then paste this in: {"action": "add", "identifier": "preview", "x": 0, "y": 0, "max_width": 1920, "max_height": 1080, "path": "/home/wpham/wisdom/FrontEnd/CSS/Resources/fillmode_default.png"}

Which is the same path I used for the image above: image

3rd commented 2 weeks ago

Then it's probably using ueberzugpp with the Kitty Graphics Protocol output, asking because using the "kitty" backend directly should work with wezterm, even if it's slower on wez than on Kitty, it should be faster that doing the round trip through ueberzugpp. Are you running it in tmux?

liketoeatcheese commented 2 weeks ago

Yea I tried with kitty backend as well but it didn't work.

I also tried with and without tmux for both backend but none worked.

ueberzugpp layer --use-escape-codes did work without tmux but not with. So I thought image.nvim would work outside of tmux but no luck

liketoeatcheese commented 2 weeks ago

Oh wait, I got this when I ran without tmux with ueberzugpp backend:

Error executing luv callback:
...al/share/nvim/lazy/image.nvim/lua/image/utils/logger.lua:54: 17:47:54.08
5269 [image.nvim] image: ueberzug died unexpectedly {
  code = 0,
  signal = 6
}
stack traceback:
        [C]: in function 'handler'
        ...al/share/nvim/lazy/image.nvim/lua/image/utils/logger.lua:54: in
function 'throw'
        ...are/nvim/lazy/image.nvim/lua/image/backends/ueberzug.lua:18: in
function <...are/nvim/lazy/image.nvim/lua/image/backends/ueberzug.lua:15>
        [C]: in function 'match_line'
        ...m/lazy/vim-illuminate/lua/illuminate/providers/regex.lua:41: in
function 'get_references'
        ...share/nvim/lazy/vim-illuminate/lua/illuminate/engine.lua:142: in
 function <...share/nvim/lazy/vim-illuminate/lua/illuminate/engine.lua:120>

        [C]: in function 'pcall'
        ...share/nvim/lazy/vim-illuminate/lua/illuminate/engine.lua:120: in
 function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
Press ENTER or type command to continu

Any thoughts?

3rd commented 2 weeks ago

No idea, you can try logging the command output or executing the same command it does outside of Neovim :shrug:

liketoeatcheese commented 2 weeks ago

All good :) I will close this