jpalardy / vim-slime

A vim plugin to give you some slime. (Emacs)
http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/
MIT License
1.83k stars 223 forks source link

Option to change bracket paste delimiters #402

Open ptonner opened 8 months ago

ptonner commented 8 months ago

When using vim-slime with euporie (a terminal-based jupyter client), there's a need to send an extra sequence to get the terminal to execute (see discussion here). Essentially a \x1b[13;5u code should be added to the end of the bracketed paste commands. Without this code, vim-slime will send code to eurporie but it won't run so it kind of breaks the flow of using slime.

I don't know exactly how this could/should be implemented, as you wouldn't want this to be added all the time if you we switching between euporie and ipython, for example. Also maybe there's some way this is already supported that I'm missing

jpalardy commented 8 months ago

Hi @ptonner

Depending on your needs, you have a few options:

If you can think of another clean injection point, let's discuss that too.

ptonner commented 8 months ago

Thanks that all sounds good. I actually discovered euporie will execute autimatically if it's a multiline string, which covers 80-90% of my needs. I can patch things with the other options.

ptonner commented 7 months ago

Actually need to reopen this b/c I realized I was wrong, and I still need this escape code even with multiline strings

I'm having trouble figuring out how to write the override, any suggestions?

Here's what I've tried

function SlimeOverride_EscapeText_python(text)                                                                                                                                                                                                                                              
   a:text .. "\x1b[13;5u"                                                                                                                                                                                                                                        
endfunction

function SlimeOverride_EscapeText_python(text)                                                                                                                                                                                                                       
     return "\x1b[200~" .. a:text .. "\x1b[201~\x1b[13;5u"
endfunction                                                                                                                                                                                                                                                                          

function SlimeOverride_EscapeText_python(text)                                                                                                                                                                                                                                       
  return call("printf", ["\x1b[200~" .. a:text .. "\x1b[13;5u"])
endfunction                                                                                                                                                                                                                                                                          

function SlimeOverride_EscapeText_python(text)
     return call("printf", [a:text .. "\x1b[13;5u"])                                                                                                                                                                                                                                    
endfunction                                                       

but none of them seem to work as intended

jpalardy commented 6 months ago

Hi @ptonner

I recommend that you find a recipe that works from the command-line first. When that works, converting it to vim-slime seems like it would be straightforward.

Also, what's your target for this?