3rd / image.nvim

🖼️ Bringing images to Neovim.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Incorrect geometry with ueberzug backend

mixolydianmel opened this issue · comments

With ueberzug backend:
2023-12-14_110047
Same file with kitty backend:
2023-12-14_111312
The terminal in the first image is Alacritty. If I test with the ueberzug backend in Kitty I get the same result. Both of these images are of a norg file with conceallevel=2. It looks like not only are the images offset on the x and y, but they are also being force-set to the max possible height given my config, which is

    backend = "ueberzug",
    integrations = {
      neorg = {
        enabled = true,
        clear_in_insert_mode = true,
        only_render_image_at_cursor = true,
      },
    },

which would take the default maximum height of 50% of the window height, which I confirmed while messing around with that option in the config. Setting the max window height percentage to 25 doesn't change the offset but does make the image smaller.

I use Hyprland on NixOS (though I'm rather new to both), and I was browsing github issues for similar problems when I eventually stumbled across jstkdng/ueberzugpp #122, but upon testing with a 1:1 monitor scale factor the results did not change. As suggested in this issue, I tried to use ueberzug on the command line to see if the offset was caused by Hyprland instead, but it worked fine.

Neovim version & info:

NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1693350652
commented

I'm not sure how far it is related to conceallevel=2, as setting it to 0 (on the fly or on the config) doesn't change anything.

My issue is that in a fresh file like this one, the first line with an image aligns properly, but the rest do not. The pattern is that in the second line with a link, the image is 1 line above than it should, on the next images 2 lines, and then it keeps changing depending on my scroll position on the following images between 1 or 2 lines of wrong offset.

![neovim logo](https://static-00.iconduck.com/assets.00/apps-neovim-icon-2048x2048-21jvoi4h.png)

![neovim logo](https://static-00.iconduck.com/assets.00/apps-neovim-icon-2048x2048-21jvoi4h.png)
![neovim logo](https://static-00.iconduck.com/assets.00/apps-neovim-icon-2048x2048-21jvoi4h.png)
![neovim logo](https://static-00.iconduck.com/assets.00/apps-neovim-icon-2048x2048-21jvoi4h.png)

I'm using a fresh installation of the plugin, I followed the readme and installed all the necessary dependencies.

This is my config.
TLDR, I'm using Alacritty and ueberzug backend (it works fine with ranger), just tweaked the max sizes so that I the images don't fill up most of my screen, and set to true clear_on_insert_mode.

My config
{
  "vhyrro/luarocks.nvim",
  priority = 1001, -- this plugin needs to run before anything else
  opts = {
    rocks = { "magick" },
  },
},
{
  "3rd/image.nvim",
  dependencies = { "luarocks.nvim" },
  config = function()
    require("image").setup({
      backend = "ueberzug",
      integrations = {
        markdown = {
          enabled = true,
          clear_in_insert_mode = true,
          download_remote_images = true,
          only_render_image_at_cursor = false,
          filetypes = { "markdown", "vimwiki" }, -- markdown extensions (ie. quarto) can go here
        },
        neorg = {
          enabled = true,
          clear_in_insert_mode = true,
          download_remote_images = true,
          only_render_image_at_cursor = false,
          filetypes = { "norg" },
        },
        html = {
          enabled = false,
        },
        css = {
          enabled = false,
        },
      },
      max_width = 50,
      max_height = 50,
      max_width_window_percentage = 90,
      max_height_window_percentage = 50,
      window_overlap_clear_enabled = false, -- toggles images when windows are overlapped
      window_overlap_clear_ft_ignore = { "cmp_menu", "cmp_docs", "" },
      editor_only_render_when_focused = false, -- auto show/hide images when the editor gains/looses focus
      tmux_show_only_in_active_window = false, -- auto show/hide images in the correct Tmux window (needs visual-activity off)
      hijack_file_patterns = { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp" }, -- render image files as images when opened
    })
  end,
},