-
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
Fix breakage w/ plugins that inadvertently trigger ALE in execute()
#3719
Fix breakage w/ plugins that inadvertently trigger ALE in execute()
#3719
Conversation
Vim does not allow the use of `:redir` from within `execute()` calls, no matter how deeply within the call chain. There are, sadly, plugins which call `execute()` for whatever reason and inadvertently trigger functions that use `:redir`, thereby raising an `E930`: >E930: Cannot use :redir inside execute() We replace all uses of `:redir => var` with `let var = execute(…)`, that resolves this. --- In `ale#sign#SetUpDefaultColumnWithoutErrorsHighlight()`, the use of the `0verbose` prefix had to be removed, as `execute()` doesn't accept it in its second argument. In fact: >execute({command} [, {silent}]) *execute()* > >[…] > > The optional {silent} argument can have these values: > "" no `:silent` used > "silent" `:silent` used > "silent!" `:silent!` used Given that `verbose` is already set to `0` on the previous line, the use of `0verbose` seems unnecessary. >function! ale#sign#SetUpDefaultColumnWithoutErrorsHighlight() abort > let l:verbose = &verbose > set verbose=0 > redir => l:output > 0verbose silent highlight SignColumn > redir end > let l:output = execute('highlight SignColumn', 'silent') > let &verbose = l:verbose >[…] The history of this part of the code shows that the `0verbose` was added first, then the let-verbose-set-verbose-let-verbose dance. I believe the `0verbose`, after that part was added, became unnecessary, but it wasn't removed. The commit which added the dance is bafe1c0, and the `0verbose` was added in d3ed1e5. Vim docs on `:[count]verbose` say: >:[count]verb[ose] {command} > Execute {command} with 'verbose' set to [count]. If > [count] is omitted one is used. ":0verbose" can be > used to set 'verbose' to zero.
@w0rp not sure what's up with the AppVeyor failure, is there a way to see why it failed? |
There is a bit of a problem: function! ale#sign#SetUpDefaultColumnWithoutErrorsHighlight() abort
let l:verbose = &verbose
set verbose=0
- redir => l:output
- 0verbose silent highlight SignColumn
- redir end
+ let l:output = execute('highlight SignColumn', '0verbose silent')
let &verbose = l:verbose This diff is wrong, because
Given that Vim docs on
|
I've squashed the bugfix commit into the first one, might as well not commit something which breaks the test suite, even if it's not in |
MR #3648 should fix this issue, if it does this MR can be closed. |
Thanks @hsanson. I'd already tried the linked PR before making this one. It didn't work for me, which is not surprising, as it's not changing the function where my debugging lead to for my issue. The particular issue that I was facing which prompted the PR was with However, this PR should fix all issues of incompatibilities with other plugins that are due to |
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.
This is sensible and will fix an edge case.
Cheers! 🍻 |
Vim does not allow the use of
:redir
from withinexecute()
calls, no matter how deeply within the call chain it occurs. There are sadly plugins that callexecute()
for whatever reasons, and inadvertently trigger ALE functions that use:redir
, thereby raising anE930
:We replace all uses of
:redir => var
withlet var = execute(…)
to resolve this.I've been trying to narrow down a minimal test case, and it's turned into a bit of a rabbit hole, as LanguageClient-neovim seems to suppress errors being displayed to the user when they use Solargraph (a Ruby language server), but not when they use Haskell Language Server. See autozimu/LanguageClient-neovim#1223 for the issue describing this.
That said, you can try this with an empty Haskell file using this
vimrc
:Just type
Prelude.
, then pressC-x C-o
. Make sure to run all this in an empty folder for best reproducibility. Also, wait a few seconds after opening the Haskell file before attempting completion to let the language server launch. It seems if you try to complete before the language server has launched, even after it's launched, a second completion attempt won't work (possibly a bug in itself).If you want to reproduce this without another plugin, you can use
vim -Nu <(echo "set rtp+=path/to/ale")
and just run these commands in order:
You should see the first time:
Every subsequent time before restarting Vim (which I believe is because the extension map is no longer a blank hash, so it's using the now cached corrupt value (another bug)):
I've tried creating a Vader test of the second method of reproduction (both with Do and Execute), but I can't seem to reproduce it in a Vader test. I thought I did a few days ago, but now I'm not so sure. I had to use
Do
, because for some reason, it seemed as if I had to be in insert mode to do the third line to prevent the popup window disappearing after I pressed colon, and it also seemed as if the second line wasn't necessary.Now, I've been no longer able to reproduce without the second line, and being in insert mode doesn't seem to matter, both with the minimal
vimrc
s and my usualvimrc
. This has been an exhausting bunch of bugs to track down and deal with (see linked issue for full details), so I'm not down for any more, but if a Vader test is really necessary for this PR, I'll keep trying, but I can't promise anything.