Skip to content

Commit

Permalink
fix(nvim): make copy clipboard work in wsl (windows) with clip.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
PunGrumpy committed Dec 28, 2024
1 parent fd0a4a5 commit bcd048d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .config/nvim/lua/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,24 @@ end)
keymap.set("n", "<leader>i", function()
require("pungrumpy.lsp").toggleInlayHints()
end)

-- Check if running on WSL
local function is_wsl()
return os.getenv("WSL_DISTRO_NAME") ~= nil
end

-- Configure clipboard for WSL using clip.exe
if is_wsl() then
vim.g.clipboard = {
name = "clip",
copy = {
["+"] = "clip.exe",
["*"] = "clip.exe",
},
paste = {
["+"] = "powershell.exe -NoProfile -Command Get-Clipboard",
["*"] = "powershell.exe -NoProfile -Command Get-Clipboard",
},
cache_enabled = 1,
}
end

0 comments on commit bcd048d

Please sign in to comment.