Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plenary's global busted definitions get picked up by LuaLS #593

Open
HiPhish opened this issue May 29, 2024 · 0 comments
Open

Plenary's global busted definitions get picked up by LuaLS #593

HiPhish opened this issue May 29, 2024 · 0 comments

Comments

@HiPhish
Copy link

HiPhish commented May 29, 2024

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:

  • 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant