From c8c85adc361d48d770fc5a5da86d06cd5809951f Mon Sep 17 00:00:00 2001
From: Martin Fischer <martin@push-f.com>
Date: Mon, 16 Jun 2025 17:30:51 +0200
Subject: fix(workstation): make vim use system clipboard

---
 user/vim/vimrc | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

(limited to 'user/vim')

diff --git a/user/vim/vimrc b/user/vim/vimrc
index 8c85c4e..952f863 100644
--- a/user/vim/vimrc
+++ b/user/vim/vimrc
@@ -3,5 +3,21 @@ syntax on
 " Don't break words in the middle.
 set linebreak
 
+" Enable easy copying between different vim instances.
+set clipboard=unnamed
+
+" Wayland clipboard workaround (see https://github.com/vim/vim/issues/5157).
+if !empty($WAYLAND_DISPLAY) && executable('wl-copy') && executable('wl-paste')
+  " enable focus reporting
+  let &t_fe = "\<Esc>[?1004h"
+  let &t_fd = "\<Esc>[?1004l"
+
+  augroup wl-clipboard
+    autocmd!
+    autocmd FocusLost * if @" != '' | call system('wl-copy --trim-newline', @") | endif
+    autocmd FocusGained * let @" = system('wl-paste -n')
+  augroup END
+endif
+
 " Enable pasting with middle mouse click in insert mode.
 set mouse=
-- 
cgit v1.2.3