@@ -1753,11 +1753,46 @@ in
17531753 type = types . submodule {
17541754 imports = [ hookModule ] ;
17551755 options . settings = {
1756+ language-dialect = mkOption {
1757+ type = types . enum [ "auto" "bash" "posix" "mksh" "bats" ] ;
1758+ description = lib . mdDoc "Shell language dialect." ;
1759+ default = "auto" ;
1760+ } ;
17561761 simplify = mkOption {
17571762 type = types . bool ;
17581763 description = "Simplify the code." ;
17591764 default = true ;
17601765 } ;
1766+ indent = mkOption {
1767+ type = types . int ;
1768+ description = lib . mdDoc "0 for tabs, >0 for number of spaces." ;
1769+ default = 0 ;
1770+ } ;
1771+ binary-next-line = mkOption {
1772+ type = types . bool ;
1773+ description = lib . mdDoc "Binary ops like && and | may start a line." ;
1774+ default = false ;
1775+ } ;
1776+ case-indent = mkOption {
1777+ type = types . bool ;
1778+ description = lib . mdDoc "Switch cases will be indented." ;
1779+ default = false ;
1780+ } ;
1781+ space-redirects = mkOption {
1782+ type = types . bool ;
1783+ description = lib . mdDoc "Redirect operators will be followed by a space." ;
1784+ default = false ;
1785+ } ;
1786+ keep-padding = mkOption {
1787+ type = types . bool ;
1788+ description = lib . mdDoc "Keep column alignment paddings." ;
1789+ default = false ;
1790+ } ;
1791+ func-next-line = mkOption {
1792+ type = types . bool ;
1793+ description = lib . mdDoc "Function opening braces are placed on a separate line." ;
1794+ default = false ;
1795+ } ;
17611796 } ;
17621797 } ;
17631798 } ;
@@ -3983,9 +4018,20 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourm
39834018 package = tools . shfmt ;
39844019 entry =
39854020 let
3986- simplify = if hooks . shfmt . settings . simplify then "-s" else "" ;
4021+ cmdArgs =
4022+ mkCmdArgs
4023+ ( with hooks . shfmt . settings ; [
4024+ [ true "-ln ${ language-dialect } " ]
4025+ [ simplify "-s" ]
4026+ [ true "-i ${ indent } " ]
4027+ [ binary-next-line "-bn" ]
4028+ [ case-indent "-ci" ]
4029+ [ space-redirects "-sr" ]
4030+ [ keep-padding "-kp" ]
4031+ [ func-next-line "-fn" ]
4032+ ] ) ;
39874033 in
3988- "${ hooks . shfmt . package } /bin/shfmt -w -l ${ simplify } " ;
4034+ "${ hooks . shfmt . package } /bin/shfmt -w -l ${ cmdArgs } " ;
39894035 } ;
39904036 single-quoted-strings =
39914037 {
0 commit comments