3rd / image.nvim

🖼️ Bringing images to Neovim.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Image is still shown when switched to another tmux window

sahinakkaya opened this issue · comments

❯ tmux -V
tmux next-3.4
❯ kitty --version
kitty 0.31.0 created by Kovid Goyal
❯ cd ~/.local/share/nvim/lazy/image.nvim
❯ git rev-parse HEAD
ec577441edca399c43d77b522870dbd7b9cd38b8
❯ cat ~/.config/tmux/tmux.conf | grep allow -A1
set-option -gq allow-passthrough on
set -g visual-activity off 

minimal.lua:

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

require("lazy").setup({
  {
    "3rd/image.nvim",
    event = "VeryLazy",
    dependencies = {
      {
        "nvim-treesitter/nvim-treesitter",
        build = ":TSUpdate",
        config = function()
          require("nvim-treesitter.configs").setup({
            ensure_installed = { "markdown" },
            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" }, -- 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,
      kitty_method = "normal",
      tmux_show_only_in_active_window = true,
    },
  },
})

package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?/init.lua;"
package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?.lua;"

vim.opt.number = true
vim.opt.conceallevel = 2
vim.opt.winbar = "image.nvim demo"
vim.opt.signcolumn = "yes:2"

local content = [[
# Hello World

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

vim.schedule(function()
  local buf = vim.api.nvim_create_buf(false, true)
  vim.api.nvim_buf_set_lines(buf, 0, -1, true, vim.split(content, "\n"))
  vim.api.nvim_buf_set_option(buf, "filetype", "markdown")
  vim.api.nvim_set_current_buf(buf)
  vim.cmd("split")
end)

After running minimal lua with nvim --clean -c ":luafile minimal.lua", image is shown correctly but when I switch to another tmux window, the image will still be there.
20240102_14h20m20s_grim

That shouldn't happen, the new Tmux version might've broken our hack.
It's working with Tmux 3.3a, I'll check with the new version and look for a different way to hook into some sort of window switch event. I'd hate to do polling, but that might be the last resort.

I skim through the documentation of kitty and I decided that using kitty with tmux is a crime. Kitty is capable of solving every problem I have with terminal emulators. (Images, ligatures, handling of keyboard and many more...) It is also capable of multiplexing. For anyone reading this, I encourage you to take some time to check what kitty is capable of. You don't need tmux.

Well, as much as I love Kovid, I don't agree with him on that, and I'd say that for me the multiplexer is more important than the terminal emulator.

Kitty is not capable of multiplexing. Multiplexing is not just being able to open multiple pseudoterms inside a terminal display.

Kitty has support for pre-configuring windows and panes on startup with --session, but that's all it does, they're not real sessions and the term probably makes things more confusing for some people, as actual sessions is the critical thing Kitty is not providing.

Of course it's not important for people that don't have terminal sessions deeply integrated into their workflow, and of course it's a hack. But, for me, it's an insane productivity booster I will never give up on.

Of course it's not important for people that don't have terminal sessions deeply integrated into their workflow

Yeah, for me this is the case. I don't use sessions that often. If I think I need sessions, I will try abduco. It is a dead project but might solve this issue.

Hi @3rd, I'm also experiencing this issue and using tmux 3.3a. Switching windows works fine, but adding a new pane or switching to a different session will cause the issue. I'm wondering if this issue is still on the table to look at.

And 2nd you, I can't imagine a life without tmux