I am studying the vim runtime system. As an exercise in package management, I placed the dracula colorscheme in pack/thirdparty/opt/vim-dracula of my 'runtimepath'.
The following sequence behaves not according to my (initial) understanding of optional packages and autoloads:
:colorscheme dracula " error (expected - haven't loaded the package, yet)
:packadd vim-dracula
:colorscheme dracula " still gives error (unexpected - I added the package?)
I experimented more with a dummy package:
" pack/thirdparty/opt/test/autoload/foo.vim
let g:foo#bar = 'bar'
function foo#baz()
return 'baz'
endfunction
Specifically, the function call works after loading the package, but the global var does not.
:echo foo#bar " error
:echo foo#baz() " error
:packadd test
:echo foo#bar " still error
:echo foo#baz() " no error this time
The function is loaded by src/userfunc.c:3947 passing TRUE to script_autoload(...).
The global var is loaded by src/evalvars.c:3474 passing FALSE to script_autoload(...). Changing to TRUE fixes the issue, but the comment suggests FALSE was intentional "otherwise it would be loaded every time when checking if a function name is a Funcref variable".
Is this in fact the desired behavior? That is, the path to an autoloaded global variable is never re-checked, but a function is?
Ubuntu 22.04.5
Vim 9.1.0698
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()