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

[nvim] Changing shell options on windows breaks AsyncRun #281

Open
mynamedjef opened this issue Jan 20, 2024 · 3 comments
Open

[nvim] Changing shell options on windows breaks AsyncRun #281

mynamedjef opened this issue Jan 20, 2024 · 3 comments

Comments

@mynamedjef
Copy link

Using this minimal setup and neovim:

filetype plugin indent on
filetype plugin on

call plug#begin()
Plug 'skywind3000/asyncrun.vim'
call plug#end()

let &shell = executable('pwsh') ? 'pwsh' : 'powershell'
let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;'
let &shellredir = '-RedirectStandardOutput %s -NoNewWindow -Wait'
let &shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
set shellquote= shellxquote=

When I run :AsyncRun, I get something like this (python x.py should just output 'ok'):

|| [python x.py]
|| C:\Users\User\AppData\Local\Temp\nvim.0\7bpwQs\asyncrun.cmd
|| [Finished in 1 seconds]

Taking a look at asyncrun.cmd:

@echo off
call %VIM_COMMAND% 
set VIM_EXITCODE=%ERRORLEVEL%
call %VIM_PAUSE% 
exit %VIM_EXITCODE%

Removing shell commands (from let &shell to set shellquote), makes AsyncRun work correctly.
My logic is that powershell doesn't invoke asyncrun.cmd correctly. Is there a fix for this?

@skywind3000
Copy link
Owner

By default, asyncrun uses shell and shellcmdflag to run command.
Changing them may cause issues.

Solution: specify dedicated shell option for asyncrun:

let g:asyncrun_shell = 'c:\windows\system32\cmd.exe'
let g:asyncrun_shellflag = '/c'

@mynamedjef
Copy link
Author

Thanks for quick response.
Tried your suggestion, but the problem is identical. Is there a way to set up default shellredir, shellpipe, shellquote and shellxquote? Since they seem to be important too

@Mitch6886
Copy link

Mitch6886 commented May 13, 2024

Hey I have made a pull request to allow changing the shell on windows with neo-vim,

#287

To enable using cmd for asyncrun

let g:asyncrun_shell = 'c:\windows\system32\cmd.exe'
let g:asyncrun_shellflag = '/c'

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