Skip to content

Format Rust, Nix and Bash via treefmt#47

Merged
philiptaron merged 5 commits intomainfrom
treefmt
Apr 18, 2024
Merged

Format Rust, Nix and Bash via treefmt#47
philiptaron merged 5 commits intomainfrom
treefmt

Conversation

@infinisil
Copy link
Member

Prompted by #46 (comment) (cc @willbush). I didn't use a bash formatter, but https://github.com/lovesegfault/beautysh seems to almost match what I've been doing!

For Nix formatting we obviously use https://github.com/NixOS/nixfmt :)

@infinisil infinisil requested a review from a team as a code owner April 17, 2024 21:43
@willbush
Copy link
Member

willbush commented Apr 17, 2024

Can we add a .git-blame-ignore-revs which helps clean up git blame a lot? It's also useful to add to ones git config (docs).

@willbush
Copy link
Member

https://github.com/lovesegfault/beautysh

Maintenance status of the repo is a little concerning. We might be able to get close to the same format with these options on https://github.com/mvdan/sh

Printer options:

  -i,  --indent uint       0 for tabs (default), >0 for number of spaces
  -bn, --binary-next-line  binary ops like && and | may start a line
  -ci, --case-indent       switch cases will be indented
  -sr, --space-redirects   redirect operators will be followed by a space
  -kp, --keep-padding      keep column alignment paddings
  -fn, --func-next-line    function opening braces are placed on a separate line

@infinisil
Copy link
Member Author

https://github.com/lovesegfault/beautysh

Maintenance status of the repo is a little concerning.

Ohh I looked at your shfmt suggestion, I thought it was https://github.com/patrickvane/shfmt, which when compared to beautysh looked more concerning. Didn't know that https://github.com/mvdan/sh provides shfmt nowadays, switching to that now!

We might be able to get close to the same format with these options on https://github.com/mvdan/sh

Turns out at least the tabs vs spaces is nicely handled without extra config because it adheres to our .editorconfig.

Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

treefmt-nix is pretty cool.

Comment on lines +77 to +79
lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.gitTracked ./.;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at that dogfooding!

# $ git config blame.ignoreRevsFile .git-blame-ignore-revs

# Reformatted all Nix files
81d712a6c4e020bf545fb931b3106aff64871962
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

81d712a6c4e020bf545fb931b3106aff64871962

# Reformatted all Bash scripts
b1306dd5ae96b0fb934256d91708733c1f850016
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@philiptaron philiptaron merged commit 6090c42 into main Apr 18, 2024
@philiptaron philiptaron deleted the treefmt branch April 18, 2024 14:44
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 this pull request may close these issues.

3 participants