summaryrefslogtreecommitdiff
path: root/core/vimrc
diff options
context:
space:
mode:
Diffstat (limited to 'core/vimrc')
-rw-r--r--core/vimrc37
1 files changed, 35 insertions, 2 deletions
diff --git a/core/vimrc b/core/vimrc
index 06d1782..017e754 100644
--- a/core/vimrc
+++ b/core/vimrc
@@ -1,5 +1,6 @@
1" One vimrc for Mac and Linux. Source of truth: /Users/xs/dev_env/core/vimrc 1" One vimrc for Mac and Linux. Source of truth: /Users/xs/dev_env/core/vimrc
2" Mac: cp core/vimrc ~/.vimrc Linux: sudo bash core/vim.sh (copies it to /etc/vimrc or /etc/vim/vimrc) 2" Mac: cp core/vimrc ~/.vimrc Linux: sudo bash core/vim.sh (copies it to /etc/vimrc or /etc/vim/vimrc)
3set nocompatible " /etc/vimrc is read before vim leaves vi mode; without this \ continuations and <leader> break
3" gt: go to next tab (right, wraps) 4" gt: go to next tab (right, wraps)
4" gT: go to previous tab (left, wraps) 5" gT: go to previous tab (left, wraps)
5" 2gt: go to tab number 2 (counted from 1 at the left) 6" 2gt: go to tab number 2 (counted from 1 at the left)
@@ -53,10 +54,42 @@ nnoremap <silent> <leader>f :<C-U>LspDocumentFormat<CR>| " \f: format file
53nnoremap <silent> <leader>em :<C-U>call ExpandMacro()<CR>| " \em: expand macro under cursor 54nnoremap <silent> <leader>em :<C-U>call ExpandMacro()<CR>| " \em: expand macro under cursor
54 55
55 56
56augroup netcat_clipboard 57" ===== Shared clipboard: RAM file /dev/shm/clip/buf on g:clip_host (same as tmux.conf) =====
58let g:clip_host = 'root@p.noml.ch'
59" One persistent ssh link (opens on first use, one key touch).
60let g:clip = ['ssh', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=yes', '-o', 'ControlPath=~/.ssh/cm-%C', '-o', 'ServerAliveInterval=30', '-o', 'ConnectTimeout=3', '-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'LogLevel=ERROR', g:clip_host]
61" push (yank): every yank or delete sends @" in a background job
62augroup ssh_clipboard
57au! 63au!
58au TextYankPost * call system("echo " . shellescape(@") . " | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1 &") 64au TextYankPost * let g:clip_job = job_start(g:clip + ['umask 077; mkdir -p /dev/shm/clip && cat >/dev/shm/clip/new && mv /dev/shm/clip/new /dev/shm/clip/buf'], {'in_io': 'pipe', 'out_io': 'null', 'err_io': 'null'}) | call ch_sendraw(g:clip_job, @") | call ch_close_in(g:clip_job)
59augroup END 65augroup END
66" pull (paste): every p P gp gP ]p [p (normal) and p P (visual) first fetches the buffer into @".
67" Waits up to 3 s for a pending push, then up to 3 s for the fetch (perl alarm kills ssh);
68" no buffer on g:clip_host yet (exit 3, e.g. after its reboot) = normal local paste;
69" any other failure prints a message and skips the paste. Counts and "x register prefixes still work.
70function! ClipPull() abort
71 let l:i = 0
72 while exists('g:clip_job') && job_status(g:clip_job) ==# 'run' && l:i < 30
73 sleep 100m
74 let l:i += 1
75 endwhile
76 let l:out = system("perl -e 'alarm 3; exec @ARGV' " . join(g:clip) . " '[ -f /dev/shm/clip/buf ] || exit 3; cat /dev/shm/clip/buf'")
77 if v:shell_error == 3
78 return 1
79 elseif v:shell_error
80 echohl ErrorMsg | echo 'clip: pull from ' . g:clip_host . ' failed or took >3s, paste skipped' | echohl None
81 return 0
82 endif
83 call setreg('"', l:out)
84 return 1
85endfunction
86for s:k in ['p', 'P', 'gp', 'gP', ']p', '[p']
87 execute 'nnoremap <expr> ' . s:k . " ClipPull() ? '" . s:k . "' : ''"
88endfor
89for s:k in ['p', 'P']
90 execute 'xnoremap <expr> ' . s:k . " ClipPull() ? '" . s:k . "' : ''"
91endfor
92" ===== end shared clipboard =====
60 93
61filetype plugin indent on 94filetype plugin indent on
62 95