From ff828927200c33bc7d3c54518c6923d46105001a Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sat, 2 Mar 2024 17:38:26 +0000 Subject: [PATCH] Add yank and put mappings --- lua/mappings.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lua/mappings.lua b/lua/mappings.lua index c522303..5bba3ed 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -21,3 +21,25 @@ vim.keymap.set('n', '', ':nohlsearch', {noremap = true}) -- Disable 'Q' from opening Ex mode vim.keymap.set('n', 'Q', '', {noremap = true}) + +-- Yank and put mappings +-- TODO: This doesn't handle all use cases, only the basics. For example, +-- this doesn't handle a local tmux session with a remote nvim in a pane. +-- if tmux#isOption('set-clipboard', 'on') || $SSH_CONNECTION !=# '' + -- " When connected to a remote session the + selection register is not + -- " available and the unnamed register is used instead. Add mappings using the + -- " z register instead. + -- noremap y "zy + -- noremap Y "zY + -- " Enable OSC 52 copy on yank. + -- call osc52#autocmd() +-- else + -- System clipboard yank/put + vim.keymap.set('', 'y', '"+y', { noremap = true }) + vim.keymap.set('', 'Y', '"+Y', { noremap = true }) + vim.keymap.set('', 'p', '"+p', { noremap = true }) + vim.keymap.set('', 'P', '"+P', { noremap = true }) +-- end + +-- Undo neovim's default mapping of Y to y$ +vim.cmd('unmap Y')