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

neovim tmux in msys2 in windows #404

Open Yousuf28 opened 7 months ago

Yousuf28 commented 7 months ago

On my windows machine I have msys2 installed. In msys2 system, I installed neovim and tmux using pacman. I was trying to run R code. When I hit ctrl-c ctrl-c I get following error.

sl

Please help to solve this.

jpalardy commented 7 months ago

Hi @Yousuf28

looking at the write_paste_file code

function! slime#common#write_paste_file(text)
  let paste_dir = fnamemodify(slime#config#resolve("paste_file"), ":p:h")
  if !isdirectory(paste_dir)
    call mkdir(paste_dir, "p")
  endif
  let output = slime#common#system("cat > %s", [slime#config#resolve("paste_file")], a:text)
  if v:shell_error
    echoerr output
  endif
endfunction

I can imagine that the paste_file, which defaults to $HOME/.slime_paste might not work in Windows. (especially the forward slash, now that I've looking at it…)

A few ideas:

Let me know how that works out, one way or another

Yousuf28 commented 7 months ago

Thanks for reply. With same setup( tmux msys2 in windows) vim-slime work with vim. It does not work with Neovim. I think the problem is with Neovim. in neovim, If I command :!echo $SHELL (with !) I get same error usr/bin/bash not such file or directory. in neovim, If I command :echo $SHELL (no ! ) I get C:\msys64\usr\bin\bash.exe in vim, If I command :!echo $SHELL I get C:/msys64/usr/bin/bash.exe and it is same for the :echo $SHELL Any idea why it is different for neovim, but same for vim?

jpalardy commented 7 months ago

I think

djhaskin987 commented 4 months ago

I figured it out. Set shellslash, shellcmdflag, shellquote, shellxquote, and hardcode the g:slime_paste_file to be some path in the msys2 scheme.

Added this to my $MYVIMRC to get it to work:

if executable("tmux")
    if has('win32')
        let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
        let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"

        "let &shell = "C:/Users/bhw/scoop/apps/msys2/current/usr/bin/bash"
        set shellslash

        set shellcmdflag=-c
        set shellquote=
        set shellxquote=
        let g:slime_paste_file = "/c/Users/bhw/.slime_paste"
        let g:slime_default_config = {"socket_name": "default", "target_pane": ":.0"}
    else
        let g:slime_default_config = {"socket_name": get(split($TMUX, ","), 0), "target_pane": ":.0"}
        let g:slime_paste_file = expand(".slime_paste")
    endif
    let g:slime_target = "tmux"
else
    let g:slime_target = "conemu"
endif

Should fix your issue. It fixed mine under the same setup.