Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neovim tmux in msys2 in windows #404

Open
Yousuf28 opened this issue Dec 3, 2023 · 4 comments
Open

neovim tmux in msys2 in windows #404

Yousuf28 opened this issue Dec 3, 2023 · 4 comments

Comments

@Yousuf28
Copy link

Yousuf28 commented Dec 3, 2023

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
Copy link
Owner

jpalardy commented Dec 3, 2023

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:

  • try overriding paste_file (let g:slime_paste_file = "..."), to a known and valid path for your machine
  • if that fails, try adding echom to the slime code to get a better idea of what's happening

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

@Yousuf28
Copy link
Author

Yousuf28 commented Dec 4, 2023

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
Copy link
Owner

jpalardy commented Dec 5, 2023

I think

  • the second one :echo $SHELL is an echo done by vim … with the $SHELL expanded in vim
  • the first one, is shelling out (and failing), to run echo in bash

@djhaskin987
Copy link
Contributor

djhaskin987 commented Feb 8, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants