yank/copy to system clipboard doesn't work in Lunarvim (neovim) and tmux

233 Views Asked by At
  • Without tmux: yank/copy works in nvim and lvim
  • With tmux: yank/copy works in nvim
  • With tmux: yank/copy doesn't work in lvim, :reg has expected behavior (* and + shows copied data, but xsel doesn't show)
  • Lvim has appropriate clipboard settings in config file (checked by :set clipboard? and let g:clipboard) both scenarios
  • Nvim doesn't have any clipboard settings in config file (checked by :set clipboard? and let g:clipboard) both scenarios

System:

$ uname -sp; nvim -v | head -1; tmux -V; echo $TERM; tmux show -s | rg -i terminal

Linux x86_64
NVIM v0.9.4
# Tried tmux 3.3 as well
tmux 3.2a
xterm-256color
default-terminal tmux-256color
terminal-overrides[0] xterm-256color:Tc
terminal-features[0] xterm*:clipboard:ccolour:cstyle:focus:title
terminal-features[1] screen*:title

$ tmux info|grep Ms
192: Ms: (string) \033]52;%p1%s;%p2%s\a

$ tmux setenv -g DISPLAY :0

~/.config/lvim/config.lua:

vim.opt.clipboard = "unnamedplus"
vim.g.clipboard = {
  name = 'xsel',
  copy = {
    ['+'] = 'xsel --nodetach -i -b',
    ['*'] = 'xsel --nodetach -i -p',
    -- doesn't work too
    -- ['+'] = 'tmux load-buffer -w -',
    -- ['*'] = 'tmux load-buffer -w -',
  },
  paste = {
    ['+'] = 'xsel -o -b',
    ['*'] = 'xsel -o -p',
    -- ['+'] = 'tmux save-buffer -',
    -- ['*'] = 'tmux save-buffer -',
  },
  cache_enabled = true,
}

Tmux

# Background for active window
set-window-option -g window-status-current-bg "#3B4252"
set -ga terminal-overrides ",xterm-256color:Tc"

# For mouse
# set -g mouse on

# For clipboard
# Try on and external as well
set -s set-clipboard off
# set -s command-alias[99] 'load-buffer=load-buffer -w'
# set -s copy-command 'xsel -b -i'
set -s copy-command 'xsel -i'
# pass "Ptmux;" escape sequences through to the terminal (3.3v)
set-window-option -g allow-passthrough on

Sources:

Thanks for help

0

There are 0 best solutions below