From ad09e704e894cae673a9f92f450f31202356a41c Mon Sep 17 00:00:00 2001 From: Patrick Auernig Date: Wed, 5 Jun 2024 16:04:27 +0200 Subject: [PATCH] Yank to clipboard explicitly Prevents the clipboard from being spammed with yanked content --- lua/valeth/keymaps.lua | 14 +++++++++----- lua/valeth/options.lua | 5 +---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lua/valeth/keymaps.lua b/lua/valeth/keymaps.lua index 3fae23b..f39825b 100644 --- a/lua/valeth/keymaps.lua +++ b/lua/valeth/keymaps.lua @@ -3,23 +3,27 @@ local map = vim.keymap.set map("n", "", "noh") map("n", "U", "redo") map("n", "Y", "y$") -map({"n", "v", "i"}, "", "w") +map({ "n", "v", "i" }, "", "w") map("n", "s", "") +-- Yank to clipboard +map({ "n", "v" }, "y", [["+y]]) +map({ "n", "v" }, "Y", [["+Y]]) + -- Move up and down visual lines for the few times I need wrapping map("n", "j", "gj") map("n", "k", "gk") -- More sensible start and end of line -map({"n", "v"}, "H", "^") -map({"n", "v"}, "L", "$") +map({ "n", "v" }, "H", "^") +map({ "n", "v" }, "L", "$") -- Exit insert mode by quickly pressing jk map("i", "jk", "l", { silent = true }) -- This avoids accidentially recording a macro -map({"n", "v"}, "", "q") -map({"n", "v"}, "q", "") +map({ "n", "v" }, "", "q") +map({ "n", "v" }, "q", "") -- Move selected lines up or down map("v", "J", ":move '>+1gv=gv") diff --git a/lua/valeth/options.lua b/lua/valeth/options.lua index 18e96b5..47a9955 100644 --- a/lua/valeth/options.lua +++ b/lua/valeth/options.lua @@ -20,9 +20,6 @@ vim.opt.foldlevelstart = 99 vim.opt.fillchars:append({ eob = "ยท" }) --- yank to clipboard, requires wl-copy command or equivalent -vim.opt.clipboard:append("unnamedplus") - vim.g.mapleader = " " @@ -37,7 +34,7 @@ aucmd("TextYankPost", { }) -- Hide cursor line while in insert mode -aucmd({"InsertEnter", "InsertLeave", "BufEnter"}, { +aucmd({ "InsertEnter", "InsertLeave", "BufEnter" }, { group = "valeth", callback = function(args) local entered_insert_mode = args.event == "InsertEnter"