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

Add g:slime_x11_lf_to_cr flag #387

Closed Henderake closed 11 months ago

Henderake commented 11 months ago

While using vim-slime with Jupyter QtConsole on Windows WSL, I experienced a multi-line issue similar to the one discussed in https://github.com/jpalardy/vim-slime/issues/297. Upon further investigation, it was discovered that these X11 applications do not break the lines on \n but rather on \r. This pull request introduces a new configuration variable g:slime_x11_lf_to_cr, enabling the substitution of \n with \r specifically when the target is X11.

jpalardy commented 11 months ago

Hi @Henderake

Thanks for the PR 👍

Since this is x11-specific, and probably application-specific, I'm not sure how generic this fix is.

Can you experiment with overrides and check if you can make it work for your use case?

Henderake commented 11 months ago

Thanks for the guide. I've managed to use overrides in my .vimrc to solve it, so I'll close the PR.

let g:slime_x11_lf_to_cr = 1

function! SlimeOverride_EscapeText_python(text)
  let escaped_text = _EscapeText_python(a:text)
  if g:slime_target =~ "x11" && exists("g:slime_x11_lf_to_cr") && g:slime_x11_lf_to_cr
      return substitute(escaped_text, '\n', '\r', 'g')
  end
  return escaped_text
endfunction