Switch to closest file configuration resolution #916
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Right now, stylua will only look for a
stylua.tomlfile in the current working directory (and, if--search-parent-directoriesis 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 src/will only use the configuration from the cwd, and will not applysrc/foo/stylua.tomlwhen formattingsrc/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 forstylua.toml. If we reach the current working directory, we stop searching any further (unless--search-parent-directorieswas specified). In this case, we would search forsrc/foo/stylua.toml,src/foo/stylua.toml, andstylua.toml, then stop.Closes #831, and Fixes #915