I'm new to neovim (and vim in general), and I'm trying to use it on Windows with MSYS2. I noticed they have a package for vim, but not for neovim. I used the neovim installed through chocolatey instead, but I couldn't get the :!{cmd} command to work. It returns "/usr/bin/bash: /s: No such file or directory". Neovim seems to work normally otherwise, including the :terminal command. Is there a way to get around this problem without changing the shell to cmd/powershell?
1 Answer
The comments by B layer and Ben Knoble were both helpful in finding the answer.
Vim correctly set the shell based on the $SHELL variable, but did not set shellcmdflag
appropriately, and that was what the /s
was, the default shellcmdflag
for cmd.exe, as stated in the :help 'shell'
file.
Setting it to -c
in my init.vim seems to have solved the problem, and a similar solution found in https://www.gitmemory.com/issue/mattn/vim-lsp-settings/234/631950449 seems to indicate that it might be useful to also set the shellxquote
and shellslash
variables. Unlike him, I did not set my PATH or the shell variable itself as I ran neovim from within MSYS2.
I added the following to vim.init so I could still use cmd.exe if I were to run nvim externally.
if $SHELL == "C:/msys64/usr/bin/bash"
let &shellcmdflag = '-c'
set shellxquote=(
set shellslash
endif
-
-
The link is dead, I'm guessing it's basically github.com/mattn/vim-lsp-settings/issues/234– CervEdSep 22, 2022 at 12:57
:h 'shell'
. Set that to the location of MSYS2's bash.exeshellcmdflag
? Not sure why it would include/s
though. I can't find anything relevant in the help matching\/s\>
/s
is.