Locate StyLua configuration files
mainStyLua searches for configuration files starting from the directory of the file being formatted and moving upwards to the current working directory.
It looks for files in this order:
stylua.tomlor.stylua.toml.editorconfig(if no StyLua config is found)- Default configuration (if no config files are found)
Key Commands:
- Use
--no-editorconfigto disable searching for.editorconfigfiles. - Use
--config-path <path>to specify a custom configuration file path. If the file is missing or malformed, StyLua will exit with an error. - Use
--search-parent-directoriesto enable recursive searching of parent directories. If no config is found in the directory tree, StyLua will then check$XDG_CONFIG_HOME,$XDG_CONFIG_HOME/stylua,$HOME/.config, and$HOME/.config/stylua.
Best Practice: It is highly recommended to keep a .stylua.toml file in your project root to ensure consistent formatting across different environments and avoid conflicts caused by searching outside the project directory.