-
-
Notifications
You must be signed in to change notification settings - Fork 386
Open
Labels
enhancementNew feature or requestNew feature or requestfeat/LuaCats AnnotationsRelated to Lua Language Server Annotations (LuaCats)Related to Lua Language Server Annotations (LuaCats)
Milestone
Description
In some cases you might need to make the plugin recognize a specific local variable as global, without declaring that variable as an actual global, one of these cases are using load and loadfile were you can pass an env variable that represents the chunk environment.
*mainFile.lua
local env = setmetatable(
{foo = function(a, b) return a == b end},
{__index = _G}
)
loadfile('./secondFile.lua', 't', env)*secondFile.lua
foo(1, 2) -- Undefined global `foo` . Lua Diagnostics.(undefined-global)So i would suggest better recognizing for load/loadfile/loadstring environment or/and a custom emmylua annotations --- @global that marks the local var as a global one.
Thanks in advance.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestfeat/LuaCats AnnotationsRelated to Lua Language Server Annotations (LuaCats)Related to Lua Language Server Annotations (LuaCats)