Skip to content
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

Spaces as default or global config #146

Closed
tiagovla opened this issue May 7, 2021 · 4 comments · Fixed by #147
Closed

Spaces as default or global config #146

tiagovla opened this issue May 7, 2021 · 4 comments · Fixed by #147

Comments

@tiagovla
Copy link

tiagovla commented May 7, 2021

So far, the transition from lua-format to stylua was flawless.

My only issue is that I need to configure it for every project because it uses tabs as default, unlike lua-format. Is there a particular reason for that?

It would be nice if it would:

  1. search for local config
  2. fallback to global config (maybe inside ~/.config/stylua.toml)
  3. fallback to default config
@JohnnyMorganz
Copy link
Owner

It's great to hear that the transition went smooth!

it uses tabs as default, unlike lua-format. Is there a particular reason for that?

StyLua is designed around the following style guide: https://roblox.github.io/lua-style-guide/, in which case Tabs are set to default. It is unlikely that will change.

fallback to global config (maybe inside ~/.config/stylua.toml)

I'm against this behaviour for the same reasons I described in
#127 (comment) - if you are working with other developers for a repo and it uses default StyLua (no config file in project), and you change from the default config in a parent/global config, then the changed config you applied would be used, rather than the formatting for the project, which is unwanted.
One thing I could do, however, is to introduce a CLI flag e.g. --search-parent-directories or similar. In this case, we would look for the config in a parent directory, or in the e.g. XDG_CONFIG_HOME. This will provide the functionality you want, whilst keeping the original behaviour as default. How does that sound?

@tiagovla
Copy link
Author

tiagovla commented May 7, 2021

Great!

@matu3ba
Copy link

matu3ba commented Sep 30, 2021

@JohnnyMorganz I want to point out that the guide is underspecified, as it does not define the tab length and rather make rules based on assumptions.
Further I would have expected from the guide to take into consideration that tab settings are an additional and inconsistent editor configuration.

If you want to have some glory editor examples not a tab width of 4 here.

And this does not even take into consideration other messed up technology having different tab-length or requiring explicit configuration.

@JohnnyMorganz
Copy link
Owner

StyLua uses indent_width as the definition of a single tab width, and a single tab is used per indentation.

I'm not sure what the guide states specifically, it is the inspiration for this formatter, but not necessarily the defining specification.

I think, to not get into a debate about tabs vs spaces, the option is open for configuration for a project, they don't need to force tabs if they don't want it. Personally, tabs are important to me for accessibility reasons

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 a pull request may close this issue.

3 participants