christoomey / vim-tmux-runner

Vim and tmux, sittin' in a tree...
MIT License
291 stars 37 forks source link

Add bracketed paste option (fixes #65) #81

Open adamobeng opened 6 years ago

adamobeng commented 6 years ago

Add a new configuration setting, VtrBracketedPaste, which wraps the text sent to tmux in the bracketed paste characters. This allows executing multiple lines in iPython 5+.

Signed-off-by: Adam Obeng github@binaryeagle.com

christoomey commented 6 years ago

Hi @adamobeng, thanks for putting this together and sharing!

I'm sort of torn on this as I was unaware of this functionality and I think it could be a nice addition, but at the same time I'm striving to keep things as simple as possible moving forward, ideally offering only the base functionality needed, while providing hooks for more complex and nuanced functionality like this bracketed paste.

With that in mind, I currently have a branch open that introduces a VtrSendKeysRaw command which will send the keys through directly. I'm wondering if your functionality could be implemented using that, rather than adding a special case to the core code. Would you mind taking a look at that branch and sharing your thoughts?

adamobeng commented 6 years ago

Thanks @christoomey!

I understand the desire to keep things simple. Are you suggesting that users would define functions to send the bracketed paste characters in their own configuration files? That seems reasonable to me, but I guess the question of whether to make it part of the core code comes down to whether bracketed paste is an allowance made for the program in the runner pane, similar in spirit to stripping leading whitespace or appending newlines.

christoomey commented 6 years ago

Hi @adamobeng, sorry for the radio silence here! In response to:

but I guess the question of whether to make it part of the core code comes down to whether bracketed paste is an allowance made for the program in the runner pane, similar in spirit to stripping leading whitespace or appending newlines.

I totally agree, and at this point I find myself implementing those configurations in the core plugin. Ideally this plugin would provide all the plumbing needed make any workflow possible, while leaving niceties like stripping or adding whitespace and the like to the user.

A good example of this is sending non-printing key commands like <C-c> or <C-d>. Way back when I implemented VtrSendCtrlD as a specific command, but I've since backed away from that with the cjt-add-send-raw-command branch which allows for the following:

nnoremap <leader>sq :VtrSendKeysRaw q<cr>
nnoremap <leader>sd :VtrSendKeysRaw ^D<cr>
nnoremap <leader>sl :VtrSendKeysRaw ^L<cr>
nnoremap <leader>sc :VtrSendKeysRaw ^C<cr>

I'm more than happy to continue this conversation and work with you to ensure that this plugin supports bracketed paste, with the clarification that my working definition of "supports" here being "doesn't prevent or make more difficult than it needs to be". I imagine this will look like a readme section describing how to use it (example function code?), as well as any needed tweaks to the VtrSendRaw command (this might need to be exposed as a function?).

With regard to your most recent commit adding support for sending portions of lines via visual selections, that feels unrelated to the bracketed change functionality we've been discussing, so I'd suggest we pull it out. Further, I'd actually prefer to avoid implementing via existing function / commands. I've long had https://github.com/christoomey/vim-tmux-runner/issues/61 in mind as the eventual goal, and I'd rather not implement a partial solution with the current commands, only to later introduce the more complete solution via a custom operator. If you'd like to take a stab at that (custom operator for sending text) I'd love that, but if not, I'll ask that we hold off on anything related to partial sending.