pop-os / cosmic-term

WIP COSMIC terminal emulator
GNU General Public License v3.0
388 stars 68 forks source link

Unable to yank / copy in neovim #315

Open tagptroll1 opened 1 month ago

tagptroll1 commented 1 month ago

Tested with

There is no way for me to extract text from neovim to the clipboard. I've tried the + and * registry, setting these as defaults in my config, ctrl + shift +C and right click copy the highlighted text.

# apt list --installed | grep cosmic-term  
cosmic-term/noble,now 0.1.0~1723901703~24.04~8c55fef amd64 

This is making the terminal unusable as a daily driver, any assistance would be greatly appreciated!

MoSal commented 1 month ago
tagptroll1 commented 1 month ago

@MoSal Sorry for the late reply. I have tried having clipboard set to unnamedplus and unnamed. I have both xsel and xclip installed (and $DISPLAY echos to :1) I'm on PopOS 24.04 With cosmic-de / wayland. inxi output for more details:

Graphics:
  Device-1: NVIDIA AD104 [GeForce RTX 4070 Ti] vendor: ASUSTeK driver: nvidia
    v: 555.58.02 arch: Lovelace pcie: speed: 5 GT/s lanes: 16 ports:
    active: none off: DP-4,DP-6 empty: DP-5,HDMI-A-2,HDMI-A-3 bus-ID: 01:00.0
    chip-ID: 10de:2782
  Device-2: AMD Raphael vendor: Micro-Star MSI driver: amdgpu v: kernel
    arch: RDNA-2 pcie: speed: 16 GT/s lanes: 16 ports: active: none empty: DP-1,
    DP-2, DP-3, HDMI-A-1, Writeback-1 bus-ID: 11:00.0 chip-ID: 1002:164e
    temp: 36.0 C
  Display: wayland server: X.org v: 1.21.1.11 with: Xwayland v: 24.1.0
    driver: gpu: nvidia,nvidia-nvswitch display-ID: 1
  Monitor-1: DP-4 model: 45WQHD240 res: 3440x1440 dpi: 82
    diag: 1165mm (45.9")
  Monitor-2: DP-6 model: Samsung C32HG7x res: 2560x1440 dpi: 93
    diag: 800mm (31.5")
  API: EGL v: 1.5 platforms: device: 0 drv: nvidia device: 2 drv: radeonsi
    device: 3 drv: swrast gbm: drv: nvidia surfaceless: drv: nvidia wayland:
    drv: nvidia x11: drv: zink inactive: device-1
  API: OpenGL v: 4.6.0 compat-v: 4.5 vendor: nvidia mesa v: 555.58.02
    glx-v: 1.4 direct-render: yes renderer: NVIDIA GeForce RTX 4070 Ti/PCIe/SSE2

edit:

xclip/noble,now 0.13-3 amd64 [installed]
xsel/noble,now 1.2.1-1 amd64 [installed]
MoSal commented 1 month ago

Since you are on Cosmic (Wayland), do you have wl-clipboard installed?

tagptroll1 commented 1 month ago

I did not, i tried to install it but it did not solve my issue. Still unable to yank or right-click copy anything out the terminal with neovim. I also noticed I also seem unable to paste anything through P in neovim. I have to ctrl+shift+V while in insert mode to actually paste anything in.

MoSal commented 1 month ago
tagptroll1 commented 1 month ago

I did them backwards, but wl-copy and wl-paste works (between different cosmic-terminals), yanking doesn't change anything with processes. I started `htop --filter "wl-copy" before opening neovim and yanking. This was the result before and after (same) image

MoSal commented 1 month ago

https://github.com/neovim/neovim/blob/0ebc4de0ff93e4edf853b177eb5b1eb898510423/runtime/autoload/provider/clipboard.vim#L96-L101

elseif !empty($WAYLAND_DISPLAY) && executable('wl-copy') && executable('wl-paste')
    let s:copy['+'] = ['wl-copy', '--type', 'text/plain']
    let s:paste['+'] = ['wl-paste', '--no-newline']
    let s:copy['*'] = ['wl-copy', '--primary', '--type', 'text/plain']
    let s:paste['*'] = ['wl-paste', '--no-newline', '--primary']
    return 'wl-copy'

If g:clipboard is undefined (check with :echo g:clipboard), and WAYLAND_DISPLAY is exported, then the above code path should be executed. So try to figure out why it's not, or why it's failing.

tagptroll1 commented 1 month ago

Hmm... when I open a new nvim instance and try to yank I get "clipboard: No provider. Try ":checkhealth" or ":h clipboard" Checking health gives me Clipboard (optional)

Closing the healthcheck, going back to my document I am suddenly able to yank to the + register, but not "" or just yanking without targeting a clipboard. This is with clipboard set to unnamed or unnamedplus.
I am not able to yank without a register, or to + or `
` before "checkhealth-ing"

I should add. I also do not get the same "clipboard: No provider..." warning when using any yank alternatives after checkinghealth. It just wont register to my computers clipboard unless i use the + register, and checking health :thinking:

MoSal commented 1 month ago

@tagptroll1

I don't know about Cosmic, but primary clipboard is not supported in all Wayland compositors. I just tested with weston, and it's not supported there for example.

% wl-copy --primary 'hi hi'
The compositor does not seem to support primary selection

You can test by passing --primary to wl-copy/wl-paste (or using Shift-Insert for pasting).

If that's the issue here, you can report it to the applicable project.

tagptroll1 commented 1 month ago

Seemed to work fine

~ $ wl-copy --primary "hihi"                                                                      21:55
~ $ wl-paste --primary                                                                            21:55
hihi
MoSal commented 1 month ago

Seemed to work fine

Cool. Update to the latest version, and test with double-clicking some text, then Shift-Insert. If that works, then the primary clipboard is definitely working in the terminal. So whatever issue you're having is probably not related to the terminal or Cosmic.