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

Support for extensions to dynamically change the interpretation of code #595

Open
devSparkle opened this issue Apr 11, 2024 · 3 comments
Open

Comments

@devSparkle
Copy link

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:

local Maid = Overture:LoadLibrary("Maid")

...gets, opaquely to the user, changed to

local Maid = require(game.Path.To.Module.Maid)

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?

@lolmanurfunny
Copy link

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):
image

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.

@devSparkle
Copy link
Author

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"})

@lolmanurfunny
Copy link

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).

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

2 participants