StyLua icon indicating copy to clipboard operation
StyLua copied to clipboard

feat: Use closest `stylua.toml` config to file being formatted

Open gabyx opened this issue 2 years ago • 7 comments

It would be nice if the formatter can be configured to stop looking for config files when reached a Git root (e.g. git rev-parse --show-toplevel) this will be useful such that when inside a lua repo and inside submodule, we stop at first .stylelua file, somehow it does not stop and merges? with the config file in the main repo, which contains the submodule...

gabyx avatar Dec 12 '23 18:12 gabyx

we stop at first .stylelua file, somehow it does not stop and merges

this sounds incorrect to me, we don't merge two stylua files together. That sounds like the underlying issue here, rather than adding something else to stop at git roots.

JohnnyMorganz avatar Dec 23 '23 10:12 JohnnyMorganz

Ah maybe you start the discovery of the style file from the current working directory, which IMO is wrong. Could that be the issue here?

gabyx avatar Dec 23 '23 13:12 gabyx

Ah yes, that seems more like it. Indeed, we just use the config found at the cwd across all the code.

I have been thinking about this though - maybe we should be using the closest configuration to the file.

I do question why you are running stylua on a sub module though. I typically think sub modules are vendored code, hence should be ignored by style tools, but maybe that is not the case for you.

JohnnyMorganz avatar Dec 23 '23 17:12 JohnnyMorganz

Von meinem iPhone gesendetAm 23.12.2023 um 18:32 schrieb JohnnyMorganz @.***>: Ah yes, that seems more like it. Indeed, we just use the config found at the cwd across all the code. I have been thinking about this though - maybe we should be using the closest configuration to the file. I do question why you are running stylua on a sub module though. I typically think sub modules are vendored code, hence should be ignored by style tools, but maybe that is not the case for you.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

gabyx avatar Dec 23 '23 19:12 gabyx

Ehm, hehe 😉 yes thats true, bitbthe astronvim distribution works differently :). But tou are right I meant I always executed the format with the cwd in the submodule and since it has a config file that one should be found, strange, I check again in a few days.

Anyway, all format tools actually do this as far as I know from clang-format - start from the file. Please check again, now a bit unsure.

gabyx avatar Dec 23 '23 19:12 gabyx

Yes, I think it is valid still. I will restructure your feature request to "Use closest configuration to file"

JohnnyMorganz avatar Dec 23 '23 19:12 JohnnyMorganz

@JohnnyMorganz : Would improve tooling much, since it will pick up the closest .stylelua.toml file and make an astronvim user install much nicer! Looking forward to this. BR

gabyx avatar Mar 27 '24 09:03 gabyx