thimc / lfimg

Image preview support for lf (list files) using Überzug
GNU General Public License v3.0
252 stars 45 forks source link

Problem with ueberzug within neovim #54

Closed aabbccddeeffggj closed 9 months ago

aabbccddeeffggj commented 9 months ago

Hi. I use a plugin to use lf within neovim. When I open a directory within neovim using lfrun the ueberzug stays on, the previews still displaying in function of the uebezurg lfrun called, which makes the previews located out of place. Anyone aware of a workaround for this? Be it disabling the ueberzug preview when inside neovim or another method. image

thimc commented 9 months ago

Hi,

I guess you could try setting the SSH_CLIENT variable prior to opening lf in your editor. Note that the value for the variable isn't important, the lfrun script simply checks its value and in the cases when it is set, image preview support is disabled.

Just to make it clear, something like this should disable ueberzug if you try running it in your shell:

SSH_CLIENT=1 lfrun
aabbccddeeffggj commented 9 months ago

Hi,

I guess you could try setting the SSH_CLIENT variable prior to opening lf in your editor. Note that the value for the variable isn't important, the lfrun script simply checks its value and in the cases when it is set, image preview support is disabled.

Just to make it clear, something like this should disable ueberzug if you try running it in your shell:

SSH_CLIENT=1 lfrun

This worked directly in the shell, but not inside neovim.

But I found the solution: 01) I'm using lf.nvim 02) I had to search through the plugins files and I found a variable he didn't specify in the documentation. 03) Basically, in the configuration of your plugin add: default_cmd = [[lf -command="set previewer ' '"]] This will remove all custom previews 04) If you don't want to remove all your previews (just remove the graphical ones), take the preview file and make a new one with it, but remove this part:

image() {
        if [ -f "$1" ] && [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1; then
        printf '{"action": "add", "identifier": "PREVIEW", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$4" "$5" "$(($2-1))" "$(($3-1))" "$1" > "$FIFO_UEBERZUG"
    else
        mediainfo "$6"
    fi
}

05) After that, put it in the plugin configuration instead: default_cmd = [[lf -command="set previewer /path/to/your/new/preview/file"]] 06) Should work now.

aabbccddeeffggj commented 9 months ago

One question: how you manage the coordinates of the ueberzug preview? I would like to know if I can make it work within neovim somehow.