Skip to content

RFC: Support Luau-syntax configuration files #125

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

vrn-sn
Copy link
Member

@vrn-sn vrn-sn commented May 30, 2025

@jackdotink
Copy link
Contributor

Looks pretty great. My bikeshed is that .luauconfig as a name is fine but I'd rather have .config.luau so that syntax highlighting just works and there's no need for more editor and especially github configuration.

@vrn-sn
Copy link
Member Author

vrn-sn commented Jun 4, 2025

I've renamed .luauconfig to .config.luau in this RFC, and I've now split the section about the timeout into analysis-time and runtime subsections.

For runtime configuration, I've introduced a new LUAUCONFIG_RUNTIME_TIMEOUT_SECONDS macro to override the default runtime timeout of two seconds.


For analysis-time configuration extraction, we adopt the same behavior described in the [user-defined type functions RFC](https://rfcs.luau.org/user-defined-type-functions.html): we simply respect the time limit that the embedding context provides through the `Frontend` API.

At runtime, the configuration extraction timeout is set to two seconds by default.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it 2 seconds per config file (my current understanding), or 2 seconds overall for config resolution? Given that the directory hierarchy matters and we'll potentially be extracting a config from every ancestor directory.

Copy link
Member Author

@vrn-sn vrn-sn Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm kind of going back and forth. My original intention was per-file, but now am unsure about a design that causes a linearly scaling hang time wrt. virtual filesystem depth.

At runtime, there's only one use case, which looks like this with a cumulative timeout: every time we see an alias in require, we attempt to resolve it by executing each VFS node's .config.luau (going up the ancestry chain as needed). If we reach the timeout limit while executing a .config.luau in the chain, we throw a timeout error.

That seems okay to me. Ultimately, the timeout is a protective feature—I'd expect that extracting information from .config.luau would be trivial in almost all cases.

@jackdotink
Copy link
Contributor

There are a few ideas I'll toss out that I think could make this better.

  • Change from camel case to lowercase. It's really a nit but it would be more consistent with the rest of Luau and this is probably the only opportunity that will exist to do this.
  • Place Luau configuration inside a luau field. This would enable other tools to store their own configuration in these files, and provide the precedent that such configuration should be under its own field. Think of a tool like a Luau optimizing compiler or a linter like Selene - having directory specific configuration can be quite useful. In Roblox the same could apply for plugins.
  • Allow for these files to be required at runtime. In the same vein as the previous suggestion, it would be useful for tools written in Luau to be able to easily access these configuration files without needing to load the file and then plop it into loadstring. I can see this being useful especially for Roblox plugins. These requires would almost always be dynamic, so maybe there is a better solution for Luau tooling being able to access Luau config.
  • Set the timeout to be really low. It can always be increased in the future and it's not like these files have access to any interesting APIs at the moment. It exists as a protective feature, but I cannot see a .config.luau file doing a computation of any kind. Setting the timeout really low would also encourage other tools to not encourage users do do computations in these files. I would recommend a timeout of 0.1 to 0.2 seconds.

Comment on lines +95 to +96
However, if both `.luaurc` and `.config.luau` are present in a directory, only the `.config.luau` file is used.
Configuration files are not merged; at most one configuration file is recognized per directory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that to remain consistent with other similar cases with require, this should be ambiguous and error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine.

An example `.config.luau` is given below.

```luau
return {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add a special case in Frontend to add a constraint on the module's return type to be LuauConfig like below. This enables autocomplete for free.

**Restrict syntax**: Limit `.config.luau` files to only contain table literals and forbid functions, loops, and other runtime constructs to reduce complexity.
Instead of spawning a new Luau VM to "parse" the file, we could simply spin up a Luau parser.

**Improve support for `.luaurc` files**: We already provide an autocomplete API for Luau-syntax files and could expose an API that facilitates editing `.luaurc` files.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@vegorov-rbx
Copy link
Collaborator

  • Set the timeout to be really low.

I think this is a bad idea. Small interrupts on a machine will cause builds to be flaky.

  • Allow for these files to be required at runtime.

This is best left to a separate proposal explaining the exact runtime semantics.
There's no need to overcomplicate the simple move from existing configuration files in this RFC.

@aatxe
Copy link
Contributor

aatxe commented Jun 10, 2025

  • Change from camel case to lowercase. It's really a nit but it would be more consistent with the rest of Luau and this is probably the only opportunity that will exist to do this.
  • Place Luau configuration inside a luau field. This would enable other tools to store their own configuration in these files, and provide the precedent that such configuration should be under its own field. Think of a tool like a Luau optimizing compiler or a linter like Selene - having directory specific configuration can be quite useful. In Roblox the same could apply for plugins.

These two are good calls IMO, and we should integrate both.

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

Successfully merging this pull request may close these issues.

6 participants