Skip to content

Conversation

@JohnnyMorganz
Copy link
Owner

Right now, stylua will only look for a stylua.toml file in the current working directory (and, if --search-parent-directories is specified, then any ancestor directories of the cwd).

This means configuration files in sub directories is not supported.

For example, in the following set up:

stylua.toml
src/
    test.lua
    foo/
        stylua.toml
        action.lua

stylua src/ will only use the configuration from the cwd, and will not apply src/foo/stylua.toml when formatting src/foo/action.lua.

This PR changes this to support looking up configuration in subdirectories.

For a given file (e.g., src/foo/action.lua), we continue searching upwards in the ancestry for stylua.toml. If we reach the current working directory, we stop searching any further (unless --search-parent-directories was specified). In this case, we would search for src/foo/stylua.toml, src/foo/stylua.toml, and stylua.toml, then stop.

Closes #831, and Fixes #915

@github-actions
Copy link
Contributor

Repo Comparison Test

No diff produced

@JohnnyMorganz JohnnyMorganz merged commit d11797b into main Nov 17, 2024
19 checks passed
@JohnnyMorganz JohnnyMorganz deleted the config-resolution branch November 17, 2024 16:13
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

Successfully merging this pull request may close these issues.

VSCode Extension ignoring stylua.toml feat: Use closest stylua.toml config to file being formatted

2 participants