From b1d1bb9e325bc3a0867fdf7c0dcc5510f668e987 Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Fri, 4 Aug 2023 18:47:09 +0000 Subject: [PATCH] fix clipboard --- vim/.vim/lua/plugin_init.lua | 3 --- vim/.vim/lua/plugins/base.lua | 6 ------ vim/.vim/lua/plugins/oscyank.lua | 22 ++++++++++++++++++++++ vim/.vim/prefs/leader.vim | 23 +---------------------- vim/.vimrc | 12 ------------ 5 files changed, 23 insertions(+), 43 deletions(-) create mode 100644 vim/.vim/lua/plugins/oscyank.lua diff --git a/vim/.vim/lua/plugin_init.lua b/vim/.vim/lua/plugin_init.lua index 4291cf5..c1a41d4 100644 --- a/vim/.vim/lua/plugin_init.lua +++ b/vim/.vim/lua/plugin_init.lua @@ -1,6 +1,3 @@ -local fn = vim.fn -local use_google = require("utils").use_google - local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ diff --git a/vim/.vim/lua/plugins/base.lua b/vim/.vim/lua/plugins/base.lua index 458d606..7997f0e 100644 --- a/vim/.vim/lua/plugins/base.lua +++ b/vim/.vim/lua/plugins/base.lua @@ -106,12 +106,6 @@ return { require("libp").setup() end, }, - { - "ojroques/nvim-osc52", - config = function() - require("config.oscyank") - end, - }, { "squk/java-syntax.vim", lazy = false, diff --git a/vim/.vim/lua/plugins/oscyank.lua b/vim/.vim/lua/plugins/oscyank.lua new file mode 100644 index 0000000..75eb243 --- /dev/null +++ b/vim/.vim/lua/plugins/oscyank.lua @@ -0,0 +1,22 @@ +return { + "ojroques/nvim-osc52", + config = function() + local function copy(lines, _) + require("osc52").copy(table.concat(lines, "\n")) + end + + local function paste() + return { vim.fn.split(vim.fn.getreg(""), "\n"), vim.fn.getregtype("") } + end + + vim.g.clipboard = { + name = "osc52", + copy = { ["+"] = copy, ["*"] = copy }, + paste = { ["+"] = paste, ["*"] = paste }, + } + + -- Now the '+' register will copy to system clipboard using OSC52 + -- vim.keymap.set("n", "c", '"+y') + -- vim.keymap.set("n", "cc", '"+yy') + end, +} diff --git a/vim/.vim/prefs/leader.vim b/vim/.vim/prefs/leader.vim index 3243a63..c27c80a 100644 --- a/vim/.vim/prefs/leader.vim +++ b/vim/.vim/prefs/leader.vim @@ -30,6 +30,7 @@ map H :wincmd H map K :wincmd K map L :wincmd L map J :wincmd J +map T :wincmd T map x :wincmd x " resize vertical split to 1/3 or 2/3 size @@ -54,25 +55,3 @@ vnoremap p "_dP nnoremap rp :VimuxOpenRunner :VimuxRunCommand '!!' :call VimuxSendKeys("Enter") nnoremap s :SessionSave - -" copy to attached terminal using the yank(1) script: -" https://github.com/sunaku/home/blob/master/bin/yank -function! Yank(text) abort - let escape = system('yank', a:text) - if v:shell_error - echoerr escape - else - call writefile([escape], '/dev/tty', 'b') - endif -endfunction -noremap y y:call Yank(@0) - -" automatically run yank(1) whenever yanking in Vim -" (this snippet was contributed by Larry Sanderson) -function! CopyYank() abort - call Yank(join(v:event.regcontents, "\n")) -endfunction - -" autocmd TextYankPost * call CopyYank() -noremap y :call CopyYank() -vnoremap y :call CopyYank() diff --git a/vim/.vimrc b/vim/.vimrc index f211038..a93dd53 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -60,18 +60,6 @@ set splitbelow " Puts new split windows to the bottom of the current set scrolljump=5 " Line to scroll when cursor leaves screen set scrolloff=3 " Minumum lines to keep above and below cursor -" let g:clipboard = #{ -" \ name: 'xsel', -" \ copy: { -" \ '+': ['xclip', '--nodetach', '-i', '-b'], -" \ '*': ['xclip', '--nodetach', '-i', '-p'], -" \ }, -" \ paste: { -" \ '+': ['xclip', '-o', '-b'], -" \ '*': ['xclip', '-o', '-p'], -" \ }, -" \ cache_enabled: 1, -" \ } set shortmess=A " disable swap set shortmess+=O set modifiable