I have Neovim installed on Windows. I use WSL for running Python and C code. So I'd like to map a key to get Neovim to run a shell command in WSL directly from the Neovim editor. But I seem to be running into an issue I haven't been able to fix on my own. When I run
:!python3 %, this is the output I get:
I did try to solve this by myself, here's more information.
I added the following two lines to my init.lua.
vim.opt.shell='wsl.exe' vim.cmd('set shellcmdflag="-c"')
If I input the
:term command, a new WSL instance opens in the editor, in the same directory - just as expected. I know that the shebang is okay because from this newly opened terminal window both
python3 code.py and
./code.py execute just as expected. The problem seems to be exclusively with the exclamation mark command.
Could I have some help with this? The end goal is a way to link Neovim key mappings to terminal commands, if there is some other (better?) way to do it.