From d8316f2a1b0d7886aabcd0f96e917129b4ae74c8 Mon Sep 17 00:00:00 2001 From: Tim Morgan Date: Fri, 15 Mar 2019 22:16:57 -0500 Subject: [PATCH] clipboard: Always copy as plain text in Wayland #9737 `wl-copy` by default tries to determine the mime type of a copied bit of text. From the [readme](https://github.com/bugaevc/wl-clipboard): > wl-copy automatically infers the type of the copied content by running > xdg-mime(1) on it. So copying a Ruby script from Nvim may store it in the Wayland clipboard as mime-type `application/x-ruby`. This is a small reproduction without Nvim: $ cat test.rb #!/usr/bin/env ruby puts 'hello world' $ cat test.rb | wl-copy $ wl-paste --list-types application/x-ruby This commit fixes that by telling wl-copy that all text copied from Nvim has the mime type `text/plain`. $ cat test.rb | wl-copy --type text/plain $ wl-paste --list-types text/plain;charset=utf-8 --- runtime/autoload/provider/clipboard.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index 2fb9d74d8d..2b06ee8c48 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -73,9 +73,9 @@ function! provider#clipboard#Executable() abort let s:cache_enabled = 0 return 'pbcopy' elseif exists('$WAYLAND_DISPLAY') && executable('wl-copy') && executable('wl-paste') - let s:copy['+'] = 'wl-copy --foreground' + let s:copy['+'] = 'wl-copy --foreground --type text/plain' let s:paste['+'] = 'wl-paste --no-newline' - let s:copy['*'] = 'wl-copy --foreground --primary' + let s:copy['*'] = 'wl-copy --foreground --primary --type text/plain' let s:paste['*'] = 'wl-paste --no-newline --primary' return 'wl-copy' elseif exists('$DISPLAY') && executable('xclip')