Skip to content

Commit a27af99

Browse files
author
Venkata Subramani Renduchintala
committed
fix(clipboard): fix wl-copy daemonization and normal-mode p mapping
- Wrap wl-copy in setsid so the background clipboard process runs in a new session, detached from nvim's process group which was killing it - Switch from string form to dict form with cache_enabled=1 for reliable cache-based paste within the same session - Add mode='v' to the p->"_dP mapping which was leaking into normal mode, silently aborting every paste attempt
1 parent 4521c43 commit a27af99

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

lua/mappings.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ wk.add({
280280
-- Edit
281281
{ "C", '"_C', desc = "Do not copy when changing" },
282282
{ "cc", '"_cc', desc = "Do not copy when changing" },
283-
{ "p", '"_dP', desc = "Paste without replacing what is was in clipboard" },
283+
{ "p", '"_dP', desc = "Paste without replacing what is was in clipboard", mode = "v" },
284284
{ "<a-j>", ":m '>+1<cr>gv=gv", desc = "[MOVE] Move block down" },
285285
{ "<a-k>", ":m '<-2<cr>gv=gv", desc = "[MOVE] Move block up" },
286286

lua/settings.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
local utils = require("utils")
22

3-
-- Force wl-copy provider; must be set before has('clipboard') is called.
4-
-- Nvim auto-detects wl-copy on Wayland, but the explicit string form pins
5-
-- the provider and skips the detection loop.
63
if vim.fn.has("unix") == 1 and vim.fn.executable("wl-copy") == 1 and vim.env.WAYLAND_DISPLAY then
7-
vim.g.clipboard = "wl-copy"
4+
vim.g.clipboard = {
5+
name = "wl-clipboard",
6+
copy = { ["+"] = {"setsid", "wl-copy", "--type", "text/plain"}, ["*"] = {"setsid", "wl-copy", "--primary", "--type", "text/plain"} },
7+
paste = { ["+"] = {"wl-paste", "--no-newline"}, ["*"] = {"wl-paste", "--no-newline", "--primary"} },
8+
cache_enabled = 1,
9+
}
810
end
911

1012
local options = {

0 commit comments

Comments
 (0)