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')