feature: add more clipboard tools to default config

This commit is contained in:
swaits committed 2024-12-26 20:35:09 -07:00
1 parent 27c5d4caba
commit 48a625ab59
2 files changed
+161 -33

No files matched your search

+98 -33
View File
@@ -50,46 +50,111 @@ Or [**lazy.nvim**](https://github.com/folke/lazy.nvim):
```lua ```lua
{ {
-- If true, prints the chosen clipboard mode/tool at startup -- Whether to log stuff to the vim console
verbose = false, verbose = false,
-- A table of tools to check, in order -- Copy/paste tools to check for
tools = { tools = {
{ -- macOS clipboard
name = "wl-clipboard", {
-- Either a string (the executable name) or a function returning boolean name = "pbcopy",
detect = function() detect = function()
local wayland_display = os.getenv("WAYLAND_DISPLAY") return vim.fn.executable("pbcopy") == 1 and vim.fn.executable("pbpaste") == 1
local wayland_runtime = os.getenv("XDG_RUNTIME_DIR") end,
local socket_path = (wayland_runtime or "") .. "/" .. (wayland_display or "") commands = {
return (vim.fn.executable("wl-copy") == 1) copy = "pbcopy",
and (vim.fn.executable("wl-paste") == 1) paste = "pbpaste",
and wayland_display ~= ""
and (vim.fn.isdirectory(socket_path) == 1)
end,
commands = {
copy = "wl-copy",
paste = "wl-paste --no-newline",
},
}, },
{ },
name = "xclip", -- Wayland and wl-copy/wl-paste
detect = "xclip", -- Will check vim.fn.executable("xclip") {
commands = { name = "wl-clipboard",
copy = "xclip -selection clipboard", detect = function()
paste = "xclip -selection clipboard -o", local wayland_display = os.getenv("WAYLAND_DISPLAY")
}, local wayland_runtime = os.getenv("XDG_RUNTIME_DIR")
local socket_path = (wayland_runtime or "") .. "/" .. (wayland_display or "")
return (vim.fn.executable("wl-copy") == 1)
and (vim.fn.executable("wl-paste") == 1)
and wayland_display ~= ""
and (vim.fn.filereadable(socket_path) == 1)
end,
commands = {
copy = "wl-copy",
paste = "wl-paste --no-newline",
}, },
{ },
name = "xsel", -- Alternative Wayland tools
detect = "xsel", {
commands = { name = "waycopy",
copy = "xsel --clipboard --input", detect = function()
paste = "xsel --clipboard --output", local wayland_display = os.getenv("WAYLAND_DISPLAY")
}, return vim.fn.executable("waycopy") == 1
and vim.fn.executable("waypaste") == 1
and wayland_display ~= nil
end,
commands = {
copy = "waycopy",
paste = "waypaste --no-newline",
}, },
},
-- X11 and xclip
{
name = "xclip",
detect = "xclip", -- Just a string, means "check if `xclip` is executable"
commands = {
copy = "xclip -selection clipboard",
paste = "xclip -selection clipboard -o",
},
},
-- X11 and xsel
{
name = "xsel",
detect = "xsel",
commands = {
copy = "xsel --clipboard --input",
paste = "xsel --clipboard --output",
},
},
-- tmux clipboard
{
name = "tmux",
detect = function()
return os.getenv("TMUX") ~= nil and vim.fn.executable("tmux") == 1
end,
commands = {
copy = "tmux load-buffer -",
paste = "tmux save-buffer -",
},
},
-- Lemonade (SSH)
{
name = "lemonade",
detect = "lemonade",
commands = {
copy = "lemonade copy",
paste = "lemonade paste",
},
},
-- DoIt client (SSH)
{
name = "doitclient",
detect = "doitclient",
commands = {
copy = "doitclient wclip",
paste = "doitclient rclip",
},
},
-- Windows win32yank
{
name = "win32yank",
detect = "win32yank.exe",
commands = {
copy = "win32yank.exe -i --crlf",
paste = "win32yank.exe -o --lf",
},
},
}, },
} }
``` ```
### Customizing Tools ### Customizing Tools
+63
View File
@@ -7,6 +7,17 @@ local M = {
-- Copy/paste tools to check for -- Copy/paste tools to check for
tools = { tools = {
-- macOS clipboard
{
name = "pbcopy",
detect = function()
return vim.fn.executable("pbcopy") == 1 and vim.fn.executable("pbpaste") == 1
end,
commands = {
copy = "pbcopy",
paste = "pbpaste",
},
},
-- Wayland and wl-copy/wl-paste -- Wayland and wl-copy/wl-paste
{ {
name = "wl-clipboard", name = "wl-clipboard",
@@ -24,6 +35,20 @@ local M = {
paste = "wl-paste --no-newline", paste = "wl-paste --no-newline",
}, },
}, },
-- Alternative Wayland tools
{
name = "waycopy",
detect = function()
local wayland_display = os.getenv("WAYLAND_DISPLAY")
return vim.fn.executable("waycopy") == 1
and vim.fn.executable("waypaste") == 1
and wayland_display ~= nil
end,
commands = {
copy = "waycopy",
paste = "waypaste --no-newline",
},
},
-- X11 and xclip -- X11 and xclip
{ {
name = "xclip", name = "xclip",
@@ -42,6 +67,44 @@ local M = {
paste = "xsel --clipboard --output", paste = "xsel --clipboard --output",
}, },
}, },
-- tmux clipboard
{
name = "tmux",
detect = function()
return os.getenv("TMUX") ~= nil and vim.fn.executable("tmux") == 1
end,
commands = {
copy = "tmux load-buffer -",
paste = "tmux save-buffer -",
},
},
-- Lemonade (SSH)
{
name = "lemonade",
detect = "lemonade",
commands = {
copy = "lemonade copy",
paste = "lemonade paste",
},
},
-- DoIt client (SSH)
{
name = "doitclient",
detect = "doitclient",
commands = {
copy = "doitclient wclip",
paste = "doitclient rclip",
},
},
-- Windows win32yank
{
name = "win32yank",
detect = "win32yank.exe",
commands = {
copy = "win32yank.exe -i --crlf",
paste = "win32yank.exe -o --lf",
},
},
}, },
}, },
} }