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

Formatting files in hidden directories #562

Closed
wincent opened this issue Sep 2, 2022 · 2 comments · Fixed by #563
Closed

Formatting files in hidden directories #562

wincent opened this issue Sep 2, 2022 · 2 comments · Fixed by #563

Comments

@wincent
Copy link
Contributor

wincent commented Sep 2, 2022

Hi @JohnnyMorganz — Thanks for building StyLua!

Wanted to ask about formatting files in hidden directories. For example, I have a bunch of Lua in my dotfiles repo under a path like .config/nvim/, and StyLua skips right over it. This means that instead of writing:

stylua .

I have to write:

stylua $PATHS_TO_HIDDEN_DIRECTORIES...

So, I've put this in a script, that does this:

stylua \
  aspects/dotfiles/files/.hammerspoon \
  aspects/nvim/files/.config

But this isn't "future proof" in the sense that I will have to remember to update this any time I add more files in other locations, or I move these directories.

Do you think it would be possible to allow StyLua to traverse hidden directories? Or do you have an alternative? Not sure if it would be a switch, or if it should just traverse hidden directories by default (in which case users would be able to use .styluaignore to avoid entering hidden directories if they didn't want them traversed).

@JohnnyMorganz
Copy link
Owner

It's definitely possible, it just hasn't been an issue yet. I think the best way is to just make it a command line flag such as --allow-hidden.
Just needs changing here

.hidden(true)

wincent added a commit to wincent/StyLua that referenced this issue Sep 2, 2022
@wincent
Copy link
Contributor Author

wincent commented Sep 2, 2022

Something like:

might do the trick. Tested locally and works for me:

  • Without --allow-hidden, stylua . does not visit hidden hierarchies:
    • --verbose shows Ignore(IgnoreMatch(Hidden)) for those entries.
  • Without --allow-hidden, stylua some/path/to/a/.dot-directory still works, as before.
  • With --allow-hidden, stylua . visits all the things.
  • cargo test still works (although no automated tests added for this).

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.

2 participants