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

ConfigResolver / Luau::parseConfig should store location of resolved config alongside alias #1417

Open
JohnnyMorganz opened this issue Sep 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@JohnnyMorganz
Copy link
Contributor

I would like to start implementing alias resolution via .luaurc for Luau LSP.

We already use Luau::ConfigResolver from Luau.Analysis, so it seems like it would be best to continue using that. Luau LSP essentially replicates the same CliConfigResolver used for luau-analyze:

struct CliConfigResolver : Luau::ConfigResolver

The problem right now, however, is that once we want to start resolving aliases, we do not have the correct location to resolve it relative to. The aliases RFC states (https://github.com/luau-lang/rfcs/blob/master/docs/require-by-string-aliases.md):

if an alias is bound to a relative path, the path will be evaluated relative to the .luaurc file in which the alias was defined.

However this location is not preserved via Luau::parseConfig, making the Config datastructure unsuitable for alias resolution in analyse.

The Luau REPL does not seem to have this issue because it decides to implement its own recursive config resolution, and ends up storing and later referencing lastSearchedDir:


As an aside, do you folks intend to support the new require-by-string + aliases in luau-analyze soon? I imagine you will hit this same issue once you do so.

@JohnnyMorganz JohnnyMorganz added the enhancement New feature or request label Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant