ekickx / clipboard-image.nvim

Neovim Lua plugin to paste image from clipboard.
MIT License
309 stars 51 forks source link

`ERROR: platform is not supported` on Linux with xclip installed #36

Closed kohane27 closed 2 years ago

kohane27 commented 2 years ago

Hello there. Hope you're doing well. Thank you for creating this handy plugin; it makes taking notes in nvim much easier!

However, I found a bug. When I first installed it it worked perfectly. Then suddenly I discovered it stopped working.

clipboard-image: require("clipboard-image.health").check()
========================================================================
## Checking dependencies
  - ERROR: platform is not supported

Platform and dependency:

❯ uname
Linux
❯ xclip -version
xclip version 0.13
Copyright (C) 2001-2008 Kim Saunders et al.
Distributed under the terms of the GNU GPL

Any input is much appreciated. Thank you:)

ekickx commented 2 years ago

Hello, sorry for the inconvenience. Can you tell me what your display server is?

echo $XDG_SESSION_TYPE
kohane27 commented 2 years ago

@ekickx

Thank you for getting back to me. I appreciate it:)

TL;DR: clipboard-image doesn't work in a tmux terminal but works in a normal terminal.

I don't see any output from echo $XDG_SESSION_TYPE:

❯ echo $XDG_SESSION_TYPE

Here's how I got the display info:

❯ loginctl
SESSION  UID USER SEAT  TTY
      2 1000 username  seat0

1 sessions listed.

❯ loginctl show-session 2 -p Type
Type=x11

So I added the following to my .xinitrc as suggested in arch wiki (I'm on Manjaro Linux):

export XDG_SESSION_TYPE=x11

rebooted and clipboard-image still doesn't work.

Then I discovered that if I tried to run clipboard-image in a non-tmux session, it works because $XDG_SESSION_TYPE is recognized:

❯ echo $XDG_SESSION_TYPE
x11

So I guess it's tmux problem? But I'm quite sure I ran clipboard-image in a tmux session before. Hope it helps:)

ekickx commented 2 years ago

Sorry for the late reply. Maybe you can try to set env var manually in your neovim lua config:

vim.env.XDG_SESSION_TYPE="x11"
kohane27 commented 2 years ago

It works! Thank you for getting back to me and providing a solution. I appreciate it:)

kohane27 commented 2 years ago

My apologies. I must have changed some settings in my .zshrc that caused clipboard-image to stop working.

I added the following line in my .zshrc:

export XDG_SESSION_TYPE="x11"

After sourcing .zshrc and now it works perfectly. Thanks again!