aboutsummaryrefslogtreecommitdiff
path: root/vim/.config
diff options
context:
space:
mode:
authorgyoder <70408179+gyoder@users.noreply.github.com>2025-07-30 12:30:31 -0600
committergyoder <70408179+gyoder@users.noreply.github.com>2025-07-30 12:30:31 -0600
commit6b312a8e49070d95ecef7d278eebff23b2079efb (patch)
treeb5e7316995e1ca3f1ec11749ea6ba5081fb89d53 /vim/.config
parent7f9cb6e767a4b136ccf043b2ade6e48e4117db8a (diff)
nvim: actually got OSC52 working
Diffstat (limited to 'vim/.config')
-rw-r--r--vim/.config/nvim/init.lua74
1 files changed, 53 insertions, 21 deletions
diff --git a/vim/.config/nvim/init.lua b/vim/.config/nvim/init.lua
index 91d8c13..90e0f89 100644
--- a/vim/.config/nvim/init.lua
+++ b/vim/.config/nvim/init.lua
@@ -68,27 +68,59 @@ vim.api.nvim_create_autocmd("TermOpen", {
vim.o.clipboard = "unnamedplus"
-vim.api.nvim_create_autocmd("TextYankPost", {
- callback = function()
- vim.highlight.on_yank()
- local osc52 = require("vim.ui.clipboard.osc52")
- local contents = vim.v.event.regcontents
- local regtype = vim.v.event.regtype
-
- if type(contents) == "string" then
- contents = { contents }
- end
-
- if regtype == "V" then
- for i, line in ipairs(contents) do
- contents[i] = line .. "\n"
- end
- end
-
- osc52.copy("+")(contents)
- osc52.copy("*")(contents)
- end,
-})
+vim.g.clipboard = {
+ name = "OSC 52",
+ copy = {
+ ["+"] = require("vim.ui.clipboard.osc52").copy("+"),
+ ["*"] = require("vim.ui.clipboard.osc52").copy("*"),
+ },
+ paste = {
+ ["+"] = require("vim.ui.clipboard.osc52").paste("+"),
+ ["*"] = require("vim.ui.clipboard.osc52").paste("*"),
+ },
+}
+-- stupid hacky workaround to make it so i can paste from tmux with OSC52
+-- https://github.com/neovim/neovim/discussions/29350#discussioncomment-10299517
+-- tracking issue about tmux behavior: https://github.com/tmux/tmux/issues/4275
+if vim.env.TMUX ~= nil then
+ local copy = {'tmux', 'load-buffer', '-w', '-'}
+ local paste = {'bash', '-c', 'tmux refresh-client -l && sleep 0.05 && tmux save-buffer -'}
+ vim.g.clipboard = {
+ name = 'tmux',
+ copy = {
+ ['+'] = copy,
+ ['*'] = copy,
+ },
+ paste = {
+ ['+'] = paste,
+ ['*'] = paste,
+ },
+ cache_enabled = 0,
+ }
+end
+--
+-- vim.api.nvim_create_autocmd("TextYankPost", {
+-- callback = function()
+-- vim.highlight.on_yank()
+-- local osc52 = require("vim.ui.clipboard.osc52")
+-- local contents = vim.v.event.regcontents
+-- local regtype = vim.v.event.regtype
+--
+-- if type(contents) == "string" then
+-- contents = { contents }
+-- end
+--
+-- if regtype == "V" then
+-- for i, line in ipairs(contents) do
+-- contents[i] = line .. "\n"
+-- end
+-- end
+--
+-- osc52.copy("+")(contents)
+-- osc52.copy("*")(contents)
+-- end,
+-- })
+--
-- Enable experimental UI in neovim-nightly
require('vim._extui').enable({})