Skip to content

Instantly share code, notes, and snippets.

@tarruda
Last active April 28, 2023 05:39
Show Gist options
  • Save tarruda/42f5236449857278f911 to your computer and use it in GitHub Desktop.
Save tarruda/42f5236449857278f911 to your computer and use it in GitHub Desktop.
Neovim clipboard plugin
import xerox
class NvimClipboard(object):
def __init__(self, vim):
self.provides = ['clipboard']
def clipboard_get(self):
return xerox.paste().split('\n')
def clipboard_set(self, lines):
xerox.copy(u'\n'.join([line.decode('utf-8') for line in lines]))
@tarruda
Copy link
Author

tarruda commented Sep 10, 2014

@jwmou Unless you configured differently, nvim should store strings as utf-8 internally so there should be no need for chardet(if needed a plugin can use vim.options['encoding'] to know the encoding beforehand)

Could you try the new version again to see if it works(requires this branch)? An alternative is to change xerox.copy('\n'.join([line.decode('utf-8') for line in lines])) to `xerox.copy(u'\n'.join([line.decode('utf-8') for line in lines]))

@jwmu
Copy link

jwmu commented Sep 17, 2014

You are right.It works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment