Comments (8)
Finally made it work. I just had to remap all put keys so it uses all plugins together.
The configuration below integrates tmux.nvim with yanky.nvim and which-key.nvim so we get the benefits of all yank-related plugins.
From the dotfiles here
require("tmux").setup {
copy_sync = {
enable = true,
sync_clipboard = false,
sync_registers = true,
},
resize = {
enable_default_keybindings = false,
},
}
-- since we want to use sync_registers with yanky.nvim, we need to
-- configure keybindings manually.
local yanky = require "yanky"
yanky.setup {
highlight = {
on_put = true,
on_yank = true,
timer = 300,
},
}
vim.keymap.set("n", "p", function()
if vim.env.TMUX then
require("tmux.copy").sync_registers()
end
yanky.put("p", false)
end)
vim.keymap.set("x", "p", function()
if vim.env.TMUX then
require("tmux.copy").sync_registers()
end
yanky.put("p", true)
end)
vim.keymap.set("n", "P", function()
if vim.env.TMUX then
require("tmux.copy").sync_registers()
end
yanky.put("P", false)
end)
vim.keymap.set("x", "P", function()
if vim.env.TMUX then
require("tmux.copy").sync_registers()
end
yanky.put("P", true)
end)
local status, which_key = pcall(require, "which-key")
if status then
vim.keymap.set("n", [["]], function()
if vim.env.TMUX then
require("tmux.copy").sync_registers()
end
which_key.show('"', { mode = "n", auto = true })
end)
vim.keymap.set("x", [["]], function()
if vim.env.TMUX then
require("tmux.copy").sync_registers()
end
which_key.show('"', { mode = "v", auto = true })
end)
end
vim.keymap.set("n", "<c-n>", "<Plug>(YankyCycleForward)")
vim.keymap.set("n", "<c-p>", "<Plug>(YankyCycleBackward)")
vim.keymap.set({ "n", "x" }, "y", "<Plug>(YankyYank)")
vim.keymap.set("n", "=p", "<Plug>(YankyPutAfterFilter)")
vim.keymap.set("n", "=P", "<Plug>(YankyPutBeforeFilter)")
require("telescope").load_extension "yank_history"
from tmux.nvim.
Heho,
unfortunately the plugin needs todo both because the sync from tmux has to run right before the paste takes place. There are no events from tmux buffer to know when new values arrive. If you find another solution im happy to try it.
I'll leave this issue open in case someone can contribute to this behaviour.
Kind regards Alexander
I see, the problem was in pasting. It's a pity neovim doesn't have TextPastePre or something like that.. Thanks for your awesome work though!
from tmux.nvim.
After recent refactoring of which-key.nvim 3.x, the which-key.nvim integration provided by @kiyoon is no longer applicable due to a bugfix.
Fortunately, folke provided a much easier approach at folke/which-key.nvim#743 (comment) which directly injects sync_registers()
into the corresponding lua method and does not require messing with keymaps.
Similarly, I re-implemented yanky.nvim integration to eliminate the need to set keymaps. Below is my config for LazyVim:
return {
{
"aserowy/tmux.nvim",
event = "VeryLazy",
opts = {
copy_sync = {
enable = true,
sync_registers_keymap_put = false, -- remove this line if you don't use yanky.nvim
sync_registers_keymap_reg = false,
},
},
config = function(_, opts)
require("tmux").setup(opts)
if vim.env.TMUX then
LazyVim.on_load("which-key.nvim", function()
local reg = require("which-key.plugins.registers")
local expand = reg.expand
function reg.expand()
require("tmux.copy").sync_registers()
return expand()
end
end)
if LazyVim.has("yanky.nvim") then
LazyVim.on_load("yanky.nvim", function()
local yanky = require("yanky")
local put = yanky.put
function yanky.put(type, is_visual, callback)
require("tmux.copy").sync_registers()
return put(type, is_visual, callback)
end
end)
end
end
end,
},
}
from tmux.nvim.
Heho,
unfortunately the plugin needs todo both because the sync from tmux has to run right before the paste takes place. There are no events from tmux buffer to know when new values arrive. If you find another solution im happy to try it.
I'll leave this issue open in case someone can contribute to this behaviour.
Kind regards
Alexander
from tmux.nvim.
Hi, is it maybe possible to add a configuration that allows custom paste function?
I'm trying to integrate yanky.nvim with this plugin together, and I think it can be possible if yanky paste function is called after sync_register.
I think it will be sick if it allows that. Thanks!
from tmux.nvim.
nice! i pinned your solution to let others find it.
from tmux.nvim.
I solved my problem with sharing clipboard by using the ojroques/nvim-osc52
plugin:
Using lazy.nvim.
This is my yanky.lua:
local opts = {
ring = {
history_length = 1000,
storage = "shada",
sync_with_numbered_registers = true,
},
system_clipboard = {
sync_with_ring = true,
},
highlight = {
on_put = true,
on_yank = true,
timer = 500,
},
preserve_cursor_position = {
enabled = true,
},
}
return {
"gbprod/yanky.nvim",
opts = opts,
keys = {
{ "y", "<Plug>(YankyYank)", mode = { "n", "x" } },
{ "p", "<Plug>(YankyPutAfter)", mode = { "n", "x" } },
{ "P", "<Plug>(YankyPutBefore)", mode = { "n", "x" } },
{ "gP", "<Plug>(YankyGPutBefore)", mode = { "n", "x" } },
{ "gp", "<Plug>(YankyGPutAfter)", mode = { "n", "x" } },
{ "<c-p>", "<Plug>(YankyCycleForward)" },
{ "<c-n>", "<Plug>(YankyCycleBackward)" },
{ "<leader>pp", "<cmd>YankyRingHistory<cr>" },
},
event = "BufReadPre",
}
tmux.lua:
local opts = {
copy_sync = {
enable = false,
},
navigation = {
cycle_navigation = true,
enable_default_keybindings = true,
persist_zoom = true,
},
resize = {
enable_default_keybindings = false,
resize_step_x = 1,
resize_step_y = 1,
},
}
return {
"aserowy/tmux.nvim",
event = "BufReadPre",
opts = opts,
}
osc52.lua:
local api, v = vim.api, vim.v
local opts = {
silent = true,
}
return {
"ojroques/nvim-osc52",
event = "BufReadPre",
opts = opts,
init = function()
local au_copy = function()
if v.event.operator == "y" and v.event.regname == "+" then
require("osc52").copy_register("+")
end
if v.event.operator == "y" and v.event.regname == "" then
require("osc52").copy_register("")
end
end
api.nvim_create_autocmd("TextYankPost", { callback = au_copy })
end,
}
I don't have to use special callbacks and my clipboard is shared between the host OS over ssh, neovim, and tmux.
from tmux.nvim.
Thus, ill let it pinned.
from tmux.nvim.
Related Issues (20)
- " keymap intersects normal workflow HOT 8
- How can I clear the screen with C-l HOT 1
- Searching for neovim process on Nix HOT 1
- statusline disappear when cmdheight=0 HOT 8
- Can not navigate between tmux panes when in vim insert mode HOT 1
- Navigating out of lazy.nvim window results in Error: WinLeave Autocommands ... HOT 6
- Enhancement: Not jump to other tmux pane if current pane is in fullscreen HOT 2
- Add wezterm support as a new backend beside tmux HOT 1
- Enabling copy_sync breaks `i_CTRL-R_CTRL-P "` HOT 3
- tmux.nvim copy_sync related crash HOT 5
- When using C-hjkl with command-line window open (q:) I get: Invalid in command-line window HOT 2
- Add option to overwrite the is_vim command. HOT 1
- Copy sync functionality
- Copy pipe
- nvim very laggy when pressing and holding find match motion (%) and clip_sync is true
- Could this support nvim-window-picker? HOT 3
- Bug Report: Copy Sync Not Working on Neovim v0.10.0 HOT 3
- Request to use a fork of vim-tmux-navigator tpm with resize support HOT 1
- Fail to map `<C-S-HJKL>` to resize splits HOT 2
- Slows down commands HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tmux.nvim.