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
This commit is contained in:
Tim Morgan 2019-03-15 22:16:57 -05:00 committed by Justin M. Keyes
parent 5c836d2ef8
commit d8316f2a1b

View File

@ -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')