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.9k stars 227 forks source link

Bracketed paste not working with zellij #379

Closed sourproton closed 1 year ago

sourproton commented 1 year ago

I have the following python file:

# %% cell 1
print("foo")

# %% cell 2
def bar(x):
    # compute y
    y = 2 * x

    return y

print(bar(1))

# %% cell 3
print("baz")

With zellij set up as the target with an ipython REPL and with g:slime_bracketed_paste=1, the cell 2 bugs because of the blank line before the return statement. The same doesn't happen in tmux, where bracketed paste is working.

According to Zellij's dev, for now a candidate fix would be to use action write instead of action write-chars and pass to it the binary equivalent of the bracketed string.

jpalardy commented 1 year ago

Hi @sourproton

slime_bracketed_paste was originally tmux-only (here, and that's where it's documented in the README). Recently, it's been added to the wezterm target (here)

Technically, there's no reason not to support it 😄

If you want to have a stab at it, let me know.

sourproton commented 1 year ago

Thank you for your answer!

As I understand, vim-slime's implementation of bracketed paste in tmux is done with the -p flag in paste-buffer -d -p -t here, whilst wezterm's implementation is done with the absence of the --no-paste flag here.

So vim-slime doesn't actually parse and treat the string to be sent to the target (it does a bit with the trailing \r and \n with wezterm but it doesn't actually wrap the string with \e[200~ and \e[201~), it uses the built-in cli command to achieve it.

Given that zellij doesn't feature this yet, and that might change, I don't see how this could be implemented right now, and I don't know if it's worth the effort to do it via vim-slime. I might take a look at zellij's source and see if I can contribute to add a bracketed paste flag there and then use it here.

jpalardy commented 1 year ago

I think that makes sense 👍

I'll be here if the situation changes.