Skip to content

Commit

Permalink
cmd/shfmt: use function_next_line from editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
scop authored and mvdan committed May 4, 2020
1 parent 05af72c commit 968589d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ binary_next_line = true # like -bn
switch_case_indent = true # like -ci
space_redirects = true # like -sr
keep_padding = true # like -kp
function_next_line = true # like -fn
# Ignore the entire "third_party" directory.
[third_party/**]
Expand Down
1 change: 1 addition & 0 deletions cmd/shfmt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ func propsOptions(props editorconfig.Section) {
syntax.SwitchCaseIndent(props.Get("switch_case_indent") == "true")(printer)
syntax.SpaceRedirects(props.Get("space_redirects") == "true")(printer)
syntax.KeepPadding(props.Get("keep_padding") == "true")(printer)
syntax.FunctionNextLine(props.Get("function_next_line") == "true")(printer)
}

func formatPath(path string, checkShebang bool) error {
Expand Down
8 changes: 8 additions & 0 deletions cmd/shfmt/testdata/scripts/editorconfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ space_redirects = true
[keep_padding.sh]
keep_padding = true

[function_next_line.sh]
function_next_line = true

-- otherknobs/shell_variant_posix.sh --
let badsyntax+
-- otherknobs/shell_variant_mksh.sh --
Expand All @@ -113,6 +116,11 @@ esac
echo foo > bar
-- otherknobs/keep_padding.sh --
echo foo bar
-- otherknobs/function_next_line.sh --
foo()
{
echo foo
}
-- ignored/.editorconfig --
root = true

Expand Down

0 comments on commit 968589d

Please sign in to comment.