I am using neovim on archlinux/WSL2, and try to communicate with the Windows clipboard in neovim.
Following the instructions in :h clipboard-wsl
, I filled in init.lua
with code:
vim.g.clipboard = {
name = 'WslClipboard',
copy = {
["+"] = 'clip.exe',
["*"] = 'clip.exe',
},
paste = {
["+"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
["*"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
},
cache_enabled = 0,
}
But when I try to yank using "+y
, I get "Clipboard: No Provider". However running :checkhealth
, I get:
Clipboard (optional)
- OK Clipboard tool found: WslClipboard
If I run echo "hello world" | clip.exe
in the terminal, all work fine: I can paste "hello world" in windows side. And so is the powershell.exe ...
command.
After I yank something, I can't find the content in '+' register or '*' register, they are just missing in the result of :reg
. So I'm inclined to think the clipboard function is not trigerred, then I tried to install xclip
, and luckily the problem is solved.
clip.exe
andpowershell.exe
command running smooth in WSL?clip.exe
andpowershell.exe
both work fine in the terminal. It would be nice if you can tell me how to debug and what to look into.{'paste': {'*': 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))', '+': 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))'}, 'cache_enabled': 0, 'name': 'WslClipboard', 'copy': {'*': 'clip.exe', '+': 'clip.exe'}}