roxma / vim-tmux-clipboard

seamless integration for vim and tmux's clipboard
MIT License
290 stars 24 forks source link

Copy tmux buffer to vim register in the same pane #9

Closed ozars closed 5 years ago

ozars commented 5 years ago

Thank you for this useful plugin.

This PR allows copying tmux buffer to vim register where the vim instance running in the pane in which tmux buffer is modified, without any need of switching panes redundantly.

I needed to copy output of some commands run inside vim in the same pane with vim using tmux (as if I was using mouse). However, it didn't work as it did in different panes. I realized FocusLost is being called after tmux creates new buffer after it's done creating a new buffer to copy text in <Prefix>[ mode. Therefore, FocusGain finds no difference between last buffer name and current buffer name. As a workaround, I kept track of the previous last buffer. See the inline comment and code for further information on how it works:

https://github.com/ozars/vim-tmux-clipboard/blob/f0a1ca23f91377527d18514a239aad6510bb796e/plugin/vimtmuxclipboard.vim#L22-L31

I expanded tab characters to spaces in the first commit, I can revert this if it's an issue.

My vim version:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Nov 28 2018 01:38:28)
Included patches: 1-549
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +extra_search      +mouse_netterm     +tag_old_static
+arabic            +farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    +tcl
+autochdir         +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
+balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
+browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          +toolbar
+cindent           +insert_expand     +path_extra        +user_commands
+clientserver      +job               +perl              +vartabs
+clipboard         +jumplist          +persistent_undo   +vertsplit
+cmdline_compl     +keymap            +postscript        +virtualedit
+cmdline_hist      +lambda            +printer           +visual
+cmdline_info      +langmap           +profile           +visualextra
+comments          +libcall           -python            +viminfo
+conceal           +linebreak         +python3           +vreplace
+cryptv            +lispindent        +quickfix          +wildignore
+cscope            +listcmds          +reltime           +wildmenu
+cursorbind        +localmap          +rightleft         +windows
+cursorshape       +lua               +ruby              +writebackup
+dialog_con_gui    +menu              +scrollbind        +X11
+diff              +mksession         +signs             -xfontset
+digraphs          +modify_fname      +smartindent       +xim
+dnd               +mouse             +startuptime       +xpm
-ebcdic            +mouseshape        +statusline        +xsmp_interact
+emacs_tags        +mouse_dec         -sun_workshop      +xterm_clipboard
+eval              +mouse_gpm         +syntax            -xterm_save
+ex_extra          -mouse_jsbterm     +tag_binary
roxma commented 5 years ago

Hi, thanks for your PR.

It seems #11 is more straight-forward

If they both addressing the same issue, I will merge #11 instead.

Please test the PR.

ozars commented 5 years ago

I've been using my fork smoothly since, but I will let you know after going through what I did why I did as it's been a while and I forgot.