Skip to content

Commit bcd048d

Browse files
committed
fix(nvim): make copy clipboard work in wsl (windows) with clip.exe
1 parent fd0a4a5 commit bcd048d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

.config/nvim/lua/config/keymaps.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,24 @@ end)
7070
keymap.set("n", "<leader>i", function()
7171
require("pungrumpy.lsp").toggleInlayHints()
7272
end)
73+
74+
-- Check if running on WSL
75+
local function is_wsl()
76+
return os.getenv("WSL_DISTRO_NAME") ~= nil
77+
end
78+
79+
-- Configure clipboard for WSL using clip.exe
80+
if is_wsl() then
81+
vim.g.clipboard = {
82+
name = "clip",
83+
copy = {
84+
["+"] = "clip.exe",
85+
["*"] = "clip.exe",
86+
},
87+
paste = {
88+
["+"] = "powershell.exe -NoProfile -Command Get-Clipboard",
89+
["*"] = "powershell.exe -NoProfile -Command Get-Clipboard",
90+
},
91+
cache_enabled = 1,
92+
}
93+
end

0 commit comments

Comments
 (0)