-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add support for ale option to override default shell used by ale #2167
Conversation
autoload/ale/job.vim
Outdated
@@ -188,11 +194,11 @@ function! ale#job#PrepareCommand(buffer, command) abort | |||
return 'cmd /s/c "' . l:command . '"' | |||
endif | |||
|
|||
if &shell =~? 'fish$\|pwsh$' | |||
return ['/bin/sh', '-c', l:command] | |||
if g:ale_shell =~? 'fish$\|pwsh$' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this should be documented in the section for g:ale_shell
autoload/ale/job.vim
Outdated
if &shell =~? 'fish$\|pwsh$' | ||
return ['/bin/sh', '-c', l:command] | ||
if g:ale_shell =~? 'fish$\|pwsh$' | ||
return ['/bin/sh', g:ale_shell_arguments, l:command] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert this to be hardcoded '-c'
to avoid conflicts with non-sh-compatible shells; because sh
is standardized we know we can pass -c
to it.
doc/ale.txt
Outdated
This variable is used to determine which shell ale will use to execute | ||
commands. This variables defaults to the value of the vim option '&shell' | ||
which corresponds to the $SHELL environment variable. For example | ||
if `$SHELL == '/bin/bash'`, but you want to use zsh, set `g:ale_shell = '/bin/zsh'.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add in a comment to suggest using g:ale_shell_arguments
if overriding this, as g:ale_shell_arguments
can pull incompatible flags from &shellcmdflag
even if the user changes shell
…ish and pwsh environments
Thanks for reviewing that @RyanSquared! I just pushed a PR that addressed those comments. I think I might need to take a look at the appveyor logs though. That build appears to be failing |
It breaks due to: https://github.com/w0rp/ale/blob/3ec20a730d1c6485ab28704f930a61c6ba426b27/autoload/ale/job.vim#L194 @w0rp both lists and strings are returned from ale#job#PrepareCommand - is that intentional, and if so, can that behavior be changed to be consistent? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think instead of replacing the built in variables with configurable ones which default to the Vim variables, make it so the default for the shell option is empty or undefined, and defining the option completely replaces all of the behavior, including the checks for cmd on Windows, fish, etc. Update the documentation to note that if you change the option, you're essentially on your own after that. You can default the shell options to the Vim variable.
If we do all of that, that will allow people to replace their shell on Windows, to use some hack or other to get fish to work, etc.
autoload/ale/job.vim
Outdated
return ['/bin/sh', '-c', l:command] | ||
endif | ||
|
||
return split(&shell) + split(&shellcmdflag) + [l:command] | ||
return [g:ale_shell] + split(g:ale_shell_arguments) + [l:command] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be wise to stick with split()
here. It's mentioned in Vim or NeoVim documentation somewhere, but I can't remember where right now.
The deal with Lists not working on Windows is that the Windows shell has no general support for quoting shell arguments. For |
Thanks for the review @w0rp. Ill make those changes |
Relevant: #2175 |
Alright I think these changes are in the direction you were talking about @w0rp. I was running into issues testing locally with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I'll take this, and I'll fix some of the formatting, which looks like it's already a bit wrong. I'll probably update the documentation so it's a bit less verbose, and I might make the variables unset instead of v:null
.
Cheers! 🍻 |
Cool! Thanks for merging this & helping with improving the PR. I'll keep an eye out for your PR so I know how to do 🍻 |
I may be wrong here, but this may have broken tests on AppVeyor. |
Correct:
|
Yeah, I broke it. |
I pushed a commit which should fix that now. I'll keep an eye on the test results. |
This PR adds the
g:ale_shell
andg:ale_shell_argument
options. Allowing the user to customize which shell ale will use to execute commands and allowing the user to specify any additional arguments they wish to pass to the execute function.The reasoning for this change it to address an issue that came up in #1968. The TL;DR is that there are some instances where Neovim attempts to run a command via
zsh
and it fails due to odd argument passing, which can be fixed by just usingbash
to run the commands.By default the
g:ale_shell
option is set to the&shell
vim variable. And theg:ale_shell_argument
option is set to-c
as was default in ale.Files changed in this PR:
autoload/ale/job.vim
- Add support forg_ale_shell
andg:ale_shell_argument
commands and use those when running commandsdoc/ale.txt
- Add documentation for new optionstest/*
- Fix tests