diff options
author | Christian Clason <c.clason@uni-graz.at> | 2022-02-13 10:32:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-13 10:32:32 +0100 |
commit | f378df846cee43a17e0d8da22fb1cb7516bcf39c (patch) | |
tree | 88ea5b0daa4b7b51f0cba705f3d2fb725ca8ecd8 /src/nvim/lua/stdlib.c | |
parent | 6f5fae08a302bce6de453425a6b1c1d851112914 (diff) | |
parent | f292dd2126f8dacd6446799ac750ab368b852f81 (diff) | |
download | rneovim-f378df846cee43a17e0d8da22fb1cb7516bcf39c.tar.gz rneovim-f378df846cee43a17e0d8da22fb1cb7516bcf39c.tar.bz2 rneovim-f378df846cee43a17e0d8da22fb1cb7516bcf39c.zip |
Merge pull request #17375 from shadmansaleh/fix/vim.g/autoload
fix: autoload variables not loaded with vim.g & nvim_get_var
Diffstat (limited to 'src/nvim/lua/stdlib.c')
-rw-r--r-- | src/nvim/lua/stdlib.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index 18a579ed0f..55b23cf0c8 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -25,6 +25,7 @@ #include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/getchar.h" +#include "nvim/globals.h" #include "nvim/lua/converter.h" #include "nvim/lua/executor.h" #include "nvim/lua/stdlib.h" @@ -408,6 +409,12 @@ int nlua_getvar(lua_State *lstate) const char *name = luaL_checklstring(lstate, 3, &len); dictitem_T *di = tv_dict_find(dict, name, (ptrdiff_t)len); + if (di == NULL && dict == &globvardict) { // try to autoload script + if (!script_autoload(name, len, false) || aborting()) { + return 0; // nil + } + di = tv_dict_find(dict, name, (ptrdiff_t)len); + } if (di == NULL) { return 0; // nil } |