Open devSparkle opened 4 months ago
require a ModuleScript by its name, instead of by path
This feature is already supported. See luau-lsp.require.fileAliases
and luau-lsp.require.directoryAliases
in settings.
How it looks (in my codebase):
There's no plugin support right now, which is heartbreaking - to put it lightly. This is by far the starkest contrast between Luau LSP and Roblox LSP.
Unfortunately, that feature makes the assumption that we are using or overriding require
, which we are not. Even if we did change that, it would not support more complex patterns, like retrieving a single function in a module by name:
local GetCentroid, GetAABB = Overture:LoadLibrary("ModelUtilities", {"GetCentroid", "GetAABB"})
Indeed. The current reality is Luau LSP is exceedingly rigid. In other words, it does not support your workflow.
When I first made the switch from Roblox LSP -> Luau LSP, boy lemme tell ya. The best way I can describe it is to imagine all of the furniture in your house disappeared in front of you (e.g. no --@module
).
Howdy'
First of all, thanks for taking the time to do this! I am currently a Roblox LSP user, as are most of the teams I've had the privilege to work with. I've developed an open-source tool called Overture, which allows us to require a ModuleScript by its name, instead of by path.
This tool allows us better organize our codebase, and while maintaining autocomplete, typechecking, and inline documentation capabilities that only
require(Path)
can usually provide. It has become essential to our workflow. I'd like to make this compatible with Luau LSP, which I find more reliable, but I've been unable to do so.Roblox LSP has a feature, which allows users to run their own Lua-based plugin that can change the code before the language server interprets it. We piggyback on this feature and basically change references to library names:
...gets, opaquely to the user, changed to
I have been unable to find the ability to achieve this with Luau LSP. Is there a venue I am missing? Would this be a capability that you're willing to add?