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

Add relative import addon. #126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

qeffects
Copy link

What this fixes: Relative requires in lua suffer from losing all emmylua/autogenerated annotations because Lua Language server can't follow through dynamic paths. Example:

local path = (...):gsub(".file", "")
local anotherFile = require(path..".anotherFile")

This allows for your library to work independent of what the external file system looks like, for example your library could be copy pasted in /libraries/* /libs/* /whatever/* and you could import adjacent files regardless.
But, anotherFile is now a completely unknown variable and you have to manually annotate it.

This together with https://github.com/Keyslam/LuaImport adds an import("./anotherFile") function that preserves type information from the required file.

@carsakiller carsakiller added the New Addon Related to adding a new addon label Mar 20, 2024
@carsakiller
Copy link
Collaborator

Please run StyLua on your submodule to apply the proper code style.

@carsakiller
Copy link
Collaborator

Please note that plugins will not be enabled automatically by the addon manager. Users will have to manually add the path to runtime.plugin.

@qeffects
Copy link
Author

Please note that plugins will not be enabled automatically by the addon manager. Users will have to manually add the path to runtime.plugin.

Can this be potentially circumvented by adding it to the addon config.json settings?

@carsakiller
Copy link
Collaborator

Probably, but that is one of the exact things I look for when checking addons for malicious code. Not saying this plugin is malicious, but the whole reason that the addon manager does not apply plugins when enabling an addon is because I don't want remote, unknown code executing on people's computers.

My plan was to pull the plugin up in VS Code for review by the user and allow enabling or ignoring the plugin, but I never got to it as I started work on a cross-editor addon manager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Addon Related to adding a new addon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants