fix clipboard

This commit is contained in:
Christian Nieves
2023-08-04 18:47:09 +00:00
parent 3d223ff976
commit b1d1bb9e32
5 changed files with 23 additions and 43 deletions

View File

@ -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({

View File

@ -106,12 +106,6 @@ return {
require("libp").setup()
end,
},
{
"ojroques/nvim-osc52",
config = function()
require("config.oscyank")
end,
},
{
"squk/java-syntax.vim",
lazy = false,

View File

@ -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", "<leader>c", '"+y')
-- vim.keymap.set("n", "<leader>cc", '"+yy')
end,
}

View File

@ -30,6 +30,7 @@ map <leader>H :wincmd H<cr>
map <leader>K :wincmd K<cr>
map <leader>L :wincmd L<cr>
map <leader>J :wincmd J<cr>
map <leader>T :wincmd T<cr>
map <leader>x :wincmd x<cr>
" resize vertical split to 1/3 or 2/3 size
@ -54,25 +55,3 @@ vnoremap <leader>p "_dP
nnoremap <leader>rp :VimuxOpenRunner<cr> :VimuxRunCommand '!!'<cr> :call VimuxSendKeys("Enter")<cr>
nnoremap <leader>s :SessionSave<CR>
" 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 <silent> <Leader>y y:<C-U>call Yank(@0)<CR>
" 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 <leader>y :call CopyYank()
vnoremap <leader>y :call CopyYank()