fix: autoload variables not loaded with vim.g & nvim_get_var

This commit is contained in:
shadmansaleh
2022-02-12 10:54:25 +06:00
parent f89f4b1e12
commit f292dd2126
4 changed files with 50 additions and 1 deletions

View File

@@ -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
}