You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plenary has its own implementation of busted, and just like the real busted it defines a bunch of global variables. This is a problem when using LuaLS because these definitions will be added to the global namespace even if I never require their source file because LuaLS sees a global assignment and adds the variable regardless of whether the file is ever sourced. I use the real busted for my tests, so this means that jumping to the definition will jump to the wrong functions.
How can we fix this? I can think of two solutions:
Use string variables and indices to assign to _G, i.e. instead of describe = mod.describe use local name = 'describe'; _G[name] = mod.describe, this will stop the language server from adding the definition.
Move the plenary busted functionality to a separate plugin that plugin authors can packadd before running tests. Then I don't have to install the plenary busted plugin and everything is fine.
Personally I think the second option would be better because it does not disrupt any existing plugins that depend on it, but it is a bit uglier in the code. What do you think? Any other idea?
The text was updated successfully, but these errors were encountered:
Hello.
Plenary has its own implementation of busted, and just like the real busted it defines a bunch of global variables. This is a problem when using LuaLS because these definitions will be added to the global namespace even if I never
require
their source file because LuaLS sees a global assignment and adds the variable regardless of whether the file is ever sourced. I use the real busted for my tests, so this means that jumping to the definition will jump to the wrong functions.How can we fix this? I can think of two solutions:
_G
, i.e. instead ofdescribe = mod.describe
uselocal name = 'describe'; _G[name] = mod.describe
, this will stop the language server from adding the definition.packadd
before running tests. Then I don't have to install the plenary busted plugin and everything is fine.Personally I think the second option would be better because it does not disrupt any existing plugins that depend on it, but it is a bit uglier in the code. What do you think? Any other idea?
The text was updated successfully, but these errors were encountered: