Obligatory note that I'm not sure who's to blame here. I have minimal understanding of the internals of plugin loading, so I have to start somewhere. If this isn't vim-plug's fault, I'll happily report this in vim/vim instead.
Explain the problem here ...
Given the following relatively minimal vimrc:
vim9script
set encoding=utf-8
set fileencoding=utf-8
set termencoding=utf-8
set nocompatible
filetype off
echo 'CPO, vimrc' &cpo
plug#begin('~/.vim9/plugged')
Plug '~/demo/'
plug#end()
and a dummy (in my example, ~/demo/) project with a plugin file MyFile.vim:
echo &cpo
fun s:func()
echo 'hi'
let x = {
\ 'x': 'y'
\ }
endfun
fun MyFile#vim8()
call s:func()
return 42
endfun
I get some extremely weird output:
❯ vim -u vim9.vimrc +qa
# Editor's note: this is the default value
CPO, vimrc aABceFs
# Editor's note, I have no idea what this utter garbage is:
aAbBcCdDeEfFgHiIjJkKlLmMnoOpPqrRsStuvwWxXyZ$!%*-+<>;
This weird behavior causes syntax errors that I initially believed to be the files parsed as Vim9, but I don't believe that's the case, considering it doesn't respond to function with an error, which it would be in vim9.
This happens somewhere when loading the plugin files themselves, and that's where my knowledge of Vim gets too flaky to tell who's to blame. It's either vim-plug or vim, and like I said, I have to start somewhere.
Also worth noting that Vim9 is the component that somehow breaks everything. This vimrc does not fail:
set encoding=utf-8
set fileencoding=utf-8
set termencoding=utf-8
set nocompatible
filetype off
echo 'CPO, vimrc' &cpo
call plug#begin('~/.vim9/plugged')
Plug '~/demo/'
call plug#end()
Yielding:
❯ vim -u vim9.vimrc +qa
CPO, vimrc aABceFs
aABceFs
... which is what I expected. Worth noting that, aside converting to legacy vimscript, these two vimrcs are functionally identical on the surface.
When I initially reported this, I also tried this on my own plugin (LunarWatcher/auto-pairs) and another plugin (mhinz/vim-startify). The symptom in the wild is a potential enormous amount of syntax errors, which is why I pushed extra for some basic Vim features in the demo file. The syntax errors are overwhelmingly the consequence of cpo being a complete mess. Worth noting that the syntax errors aren't tripped, because the code is in a set of functions, neither of which are executed. CPO being completely screwed results in line continuations being disabled, which is in line with :h E10.
vim-startify in particular yielded problems in an autoload file; this autoload file is loaded via the plugin file, as a consequence of cpo cascading down into called autoload files.
While I haven't made an example for this, it's trivial to prove it isn't a surface level Vim9 issue; converting MyFile to an autoload file instead of a plugin file, and adding echo MyFile#vim8() prints the right cpoptions, and everything runs as expected. This means it is clearly an issue when the plugin files themselves are loaded; and I don't know whether vim does that itself, or if that's dealt with by vim-plug. Again, if it isn't vim-plug's fault, I'll happily move this over to Vim's repo instead
Obligatory note that I'm not sure who's to blame here. I have minimal understanding of the internals of plugin loading, so I have to start somewhere. If this isn't vim-plug's fault, I'll happily report this in vim/vim instead.
Explain the problem here ...
Given the following relatively minimal vimrc:
and a dummy (in my example,
~/demo/
) project with a plugin fileMyFile.vim
:I get some extremely weird output:
This weird behavior causes syntax errors that I initially believed to be the files parsed as Vim9, but I don't believe that's the case, considering it doesn't respond to
function
with an error, which it would be in vim9.This happens somewhere when loading the plugin files themselves, and that's where my knowledge of Vim gets too flaky to tell who's to blame. It's either vim-plug or vim, and like I said, I have to start somewhere.
Also worth noting that Vim9 is the component that somehow breaks everything. This vimrc does not fail:
Yielding:
... which is what I expected. Worth noting that, aside converting to legacy vimscript, these two vimrcs are functionally identical on the surface.
When I initially reported this, I also tried this on my own plugin (
LunarWatcher/auto-pairs
) and another plugin (mhinz/vim-startify
). The symptom in the wild is a potential enormous amount of syntax errors, which is why I pushed extra for some basic Vim features in the demo file. The syntax errors are overwhelmingly the consequence ofcpo
being a complete mess. Worth noting that the syntax errors aren't tripped, because the code is in a set of functions, neither of which are executed. CPO being completely screwed results in line continuations being disabled, which is in line with:h E10
.vim-startify in particular yielded problems in an autoload file; this autoload file is loaded via the plugin file, as a consequence of
cpo
cascading down into called autoload files.While I haven't made an example for this, it's trivial to prove it isn't a surface level Vim9 issue; converting
MyFile
to an autoload file instead of a plugin file, and addingecho MyFile#vim8()
prints the right cpoptions, and everything runs as expected. This means it is clearly an issue when the plugin files themselves are loaded; and I don't know whether vim does that itself, or if that's dealt with by vim-plug. Again, if it isn't vim-plug's fault, I'll happily move this over to Vim's repo instead