mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
6.99k stars 333 forks source link

Set flags as comments inside of a file #951

Closed sarmong closed 1 year ago

sarmong commented 1 year ago

-kp, --keep-padding is handy for config files, however it is very annoying when writing scripts because with this option, shfmt doesn't fix extra indentation.

  1. It would be nice to set this rule as a comment at the top of the file to only apply to certain files
  2. Maybe this rule could retain spaces only in-between text, but format them when at the beginning of a line?
mvdan commented 1 year ago

Have you seen https://github.com/mvdan/sh/issues/658? The flag is frozen and will be removed in a future v4, so you probably don't want to rely on it.

sarmong commented 1 year ago

Thanks, I will probably stop using this feature then.

I hope that it will be resurrected in another way in the future, because it really helps navigating config files such as bspwmrc