(nvim) use xorg or wayland for clipboard

This commit is contained in:
jc 2024-10-15 17:10:50 -04:00
commit 20dd4e841b

View file

@ -1,6 +1,22 @@
local Utils = require("juancwu.utils") local Utils = require("juancwu.utils")
if Utils.os.is_linux() then if Utils.os.is_linux() then
local wayland_display = os.getenv("WAYLAND_DISPLAY")
local clipboard_cmd = "xclip"
if wayland_display then
vim.g.clipboard = {
name = "wl-clipboard",
copy = {
['+'] = "wl-copy",
['*'] = "wl-copy",
},
paste = {
['+'] = "wl-paste",
['*'] = "wl-paste",
},
cache_enabled = 1,
}
else
vim.g.clipboard = { vim.g.clipboard = {
name = "xclip", name = "xclip",
copy = { copy = {
@ -13,6 +29,7 @@ if Utils.os.is_linux() then
}, },
cache_enabled = 1, cache_enabled = 1,
} }
end
elseif Utils.os.is_mac() then elseif Utils.os.is_mac() then
vim.opt.clipboard:append { "unnamedplus" } vim.opt.clipboard:append { "unnamedplus" }
elseif Utils.os.is_wsl() then elseif Utils.os.is_wsl() then