kelly-lin / ranger.nvim

Ranger plugin for neovim
MIT License
152 stars 13 forks source link

Can preview image like ranger in Shell? #10

Closed guxuerui closed 1 year ago

guxuerui commented 1 year ago

Hello, can I preview image byranger.nvim? Just like use ranger in Shell, for example this below, and what should I config?

image

kelly-lin commented 1 year ago

Hey @guxuerui,

ranger.nvim should display exactly the same thing as running ranger in the command line without any configuration.

Is ranger.nvim displaying something different to ranger? If it is, do you mind sharing a screenshot?

guxuerui commented 1 year ago

Hey @guxuerui,

ranger.nvim should display exactly the same thing as running ranger in the command line without any configuration.

Is ranger.nvim displaying something different to ranger? If it is, do you mind sharing a screenshot?

Yes, I can preview image use ranger in command line, but cant't in ranger.nvim.

I'm using Iterm2, my nvim version is 0.9.0 and my ranger.nvim configuation is :

return {
    {
        "kelly-lin/ranger.nvim",
        config = function()
            require("ranger-nvim").setup({
                enable_cmds = true,
                replace_netrw = true,
                ui = {
                    border = "rounded",
                    width = 0.6,
                    height = 0.6,
                },
            })
            vim.api.nvim_set_keymap("n", "<leader>er", "", {
                noremap = true,
                callback = function()
                    require("ranger-nvim").open(true)
                end,
            })
        end,
    },
}

Screenshot: image

kelly-lin commented 1 year ago

@guxuerui are you using something like ueberzug underneath iterm2 to view the images? Or is images supported directly through iterm2?

guxuerui commented 1 year ago

@guxuerui are you using something like ueberzug underneath iterm2 to view the images? Or is images supported directly through iterm2?

Directly through iterm2 and ranger.

In ranger configuration, I have set preview_images to true, and I can also see that when I view the settings in ranger.nvim.

So, I am quite puzzled, could it be that I am missing some ranger.nvim configurations which are causing the inability to preview images?

guxuerui commented 1 year ago

@guxuerui are you using something like ueberzug underneath iterm2 to view the images? Or is images supported directly through iterm2?

Directly through iterm2 and ranger.

In ranger configuration, I have set preview_images to true, and I can also see that when I view the settings in ranger.nvim.

So, I am quite puzzled, could it be that I am missing some ranger.nvim configurations which are causing the inability to preview images?

Or, is it because image preview is not supported in Neovim itself?

kelly-lin commented 1 year ago

@guxuerui are you using something like ueberzug underneath iterm2 to view the images? Or is images supported directly through iterm2?

Directly through iterm2 and ranger. In ranger configuration, I have set preview_images to true, and I can also see that when I view the settings in ranger.nvim. So, I am quite puzzled, could it be that I am missing some ranger.nvim configurations which are causing the inability to preview images?

Or, is it because image preview is not supported in Neovim itself?

It is possible.

What happens when you run ranger from an integrated terminal from neovim (follow the steps below)?

guxuerui commented 1 year ago

I followed these steps, but I still can't preview the image. Maybe I should give up on this feature😂. Thank you for your help!

kohane27 commented 1 year ago

Maybe the following info is useful.

The following is from ranger: 2023-08-15-22-34-50

The following is from ranger.nvim:

2023-08-15-22-35-24

You can see that the image position is "off", but it works nonetheless. Previewing images in the terminal is always janky. Is it possible that your image is "spawned off the screen" somehow? Maybe you can try the following:

 ui = {
    border = "none",
    height = 1,
    width = 1,
    x = 0.5,
    y = 0.5,
  }

and play with the number.

System info:

OS: ArchLinux WM: sway Terminal: tmux

ranger version: ranger 1.9.3 Python version: 3.11.3 (main, Jun 5 2023, 09:32:32) [GCC 13.1.1 20230429] ueberzugpp 2.9.0

ariel-frischer commented 8 months ago

I'm seeing the same issue, using kitty terminal w/ pillow I guess for image previews. I see previews from console ranger but not from neovim ranger, using integrated :terminal the previews don't work either. Why was this closed?

exosyphon commented 4 months ago

I am also not seeing the image previews

guxuerui commented 4 months ago

I'm seeing the same issue, using kitty terminal w/ pillow I guess for image previews. I see previews from console ranger but not from neovim ranger, using integrated :terminal the previews don't work either. Why was this closed?

Sorry, because I tried many methods but couldn't solve the problem, I gave up using this feature and eventually closed this issue.