From 968589db6e321f633afc263c53219e26e6b88679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 4 May 2020 22:29:35 +0300 Subject: [PATCH] cmd/shfmt: use function_next_line from editorconfig --- README.md | 1 + cmd/shfmt/main.go | 1 + cmd/shfmt/testdata/scripts/editorconfig.txt | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 12c8e4280..837442b87 100644 --- a/README.md +++ b/README.md @@ -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/**] diff --git a/cmd/shfmt/main.go b/cmd/shfmt/main.go index 62fb20e06..9ced7cbb5 100644 --- a/cmd/shfmt/main.go +++ b/cmd/shfmt/main.go @@ -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 { diff --git a/cmd/shfmt/testdata/scripts/editorconfig.txt b/cmd/shfmt/testdata/scripts/editorconfig.txt index d1b1557b9..0070bdc4e 100644 --- a/cmd/shfmt/testdata/scripts/editorconfig.txt +++ b/cmd/shfmt/testdata/scripts/editorconfig.txt @@ -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 -- @@ -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