nvim: fix clipboard on WSL

This commit is contained in:
Fernando Schauenburg 2024-08-23 20:24:09 +02:00
parent 801f0cc7b3
commit 88ea5719c7

View file

@ -23,12 +23,6 @@ M.setup = function()
o.modelines = 0 -- never use modelines
o.fileformats = "unix,mac,dos" -- prioritize unix <EOL> format
o.winblend = 8 -- minimum transparency for floating windows
-- Schedule the setting after `UiEnter` because it can increase startup-time.
vim.schedule(function()
o.clipboard = "unnamedplus" -- synchronize with system clipboard
end)
o.swapfile = false -- don"t use swap files
o.writebackup = true -- Make a backup before writing a file...
o.backup = false -- ...but don"t keep it around.
@ -44,6 +38,23 @@ M.setup = function()
"s100", -- limit size of remembered items to this many KiB
}
--- Clipboard
if vim.fn.has("wsl") == 1 then
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,
}
end
o.clipboard = "unnamedplus" -- synchronize with system clipboard
-- Searching
o.ignorecase = true -- Ignore case when searching...
o.smartcase = true -- ...unless pattern contains uppercase characters.