jpalardy/vim-slime

Option to change bracket paste delimiters

ptonner opened this issue · 4 comments

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

Hi @ptonner

Depending on your needs, you have a few options:

  • use a language override (link)
  • change your mappings (maybe only when using this client) to send a text snippet (as discussed) after a text payload

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

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.

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

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?