From 62488a6d3ef66e7c9d9e44cab98f895085954db7 Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Wed, 24 Dec 2025 19:41:48 +0800 Subject: [PATCH 1/4] Fix `call_parentheses = Input` don't work in editorconfig --- src/editorconfig.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/editorconfig.rs b/src/editorconfig.rs index 6cc12968..9cb28ae2 100644 --- a/src/editorconfig.rs +++ b/src/editorconfig.rs @@ -62,7 +62,8 @@ property_choice! { (Always, "always"), (NoSingleString, "nosinglestring"), (NoSingleTable, "nosingletable"), - (None, "none") + (None, "none"), + (Input, "input") } property_choice! { @@ -134,6 +135,7 @@ fn load(mut config: Config, properties: &Properties) -> Config { config.call_parentheses = CallParenType::NoSingleTable } CallParenthesesChoice::None => config.call_parentheses = CallParenType::None, + CallParenthesesChoice::Input => config.call_parentheses = CallParenType::Input, } } if let Ok(space_after_function_names) = properties.get::() { From 2f21a7e0e33f5b9444ae281bb9da8107b51705e4 Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Wed, 24 Dec 2025 19:49:05 +0800 Subject: [PATCH 2/4] fixup! Fix `call_parentheses = Input` don't work in editorconfig make it more readable --- src/editorconfig.rs | 115 ++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 68 deletions(-) diff --git a/src/editorconfig.rs b/src/editorconfig.rs index 9cb28ae2..20380192 100644 --- a/src/editorconfig.rs +++ b/src/editorconfig.rs @@ -91,92 +91,71 @@ property_choice! { // Override StyLua config with EditorConfig properties fn load(mut config: Config, properties: &Properties) -> Config { if let Ok(end_of_line) = properties.get::() { - match end_of_line { - EndOfLine::Cr | EndOfLine::Lf => config.line_endings = LineEndings::Unix, - EndOfLine::CrLf => config.line_endings = LineEndings::Windows, - } + config.line_endings = match end_of_line { + EndOfLine::Cr | EndOfLine::Lf => LineEndings::Unix, + EndOfLine::CrLf => LineEndings::Windows, + }; } if let Ok(indent_size) = properties.get::() { - match indent_size { - IndentSize::Value(indent_width) => config.indent_width = indent_width, - IndentSize::UseTabWidth => { - if let Ok(TabWidth::Value(indent_width)) = properties.get::() { - config.indent_width = indent_width - } - } - } + config.indent_width = match indent_size { + IndentSize::Value(indent_width) => indent_width, + IndentSize::UseTabWidth => match properties.get::() { + Ok(TabWidth::Value(tab_width)) => tab_width, + _ => config.indent_width, + }, + }; } if let Ok(indent_style) = properties.get::() { - match indent_style { - IndentStyle::Tabs => config.indent_type = IndentType::Tabs, - IndentStyle::Spaces => config.indent_type = IndentType::Spaces, - } + config.indent_type = match indent_style { + IndentStyle::Tabs => IndentType::Tabs, + IndentStyle::Spaces => IndentType::Spaces, + }; } if let Ok(max_line_length) = properties.get::() { - match max_line_length { - MaxLineLen::Value(column_width) => config.column_width = column_width, - MaxLineLen::Off => config.column_width = usize::MAX, - } + config.column_width = match max_line_length { + MaxLineLen::Value(column_width) => column_width, + MaxLineLen::Off => usize::MAX, + }; } if let Ok(quote_type) = properties.get::() { - match quote_type { - QuoteTypeChoice::Double => config.quote_style = QuoteStyle::AutoPreferDouble, - QuoteTypeChoice::Single => config.quote_style = QuoteStyle::AutoPreferSingle, - QuoteTypeChoice::Auto => (), - } + config.quote_style = match quote_type { + QuoteTypeChoice::Double => QuoteStyle::AutoPreferDouble, + QuoteTypeChoice::Single => QuoteStyle::AutoPreferSingle, + QuoteTypeChoice::Auto => config.quote_style, + }; } if let Ok(call_parentheses) = properties.get::() { - match call_parentheses { - CallParenthesesChoice::Always => config.call_parentheses = CallParenType::Always, - CallParenthesesChoice::NoSingleString => { - config.call_parentheses = CallParenType::NoSingleString - } - CallParenthesesChoice::NoSingleTable => { - config.call_parentheses = CallParenType::NoSingleTable - } - CallParenthesesChoice::None => config.call_parentheses = CallParenType::None, - CallParenthesesChoice::Input => config.call_parentheses = CallParenType::Input, - } + config.call_parentheses = match call_parentheses { + CallParenthesesChoice::Always => CallParenType::Always, + CallParenthesesChoice::NoSingleString => CallParenType::NoSingleString, + CallParenthesesChoice::NoSingleTable => CallParenType::NoSingleTable, + CallParenthesesChoice::None => CallParenType::None, + CallParenthesesChoice::Input => CallParenType::Input, + }; } if let Ok(space_after_function_names) = properties.get::() { - match space_after_function_names { - SpaceAfterFunctionNamesChoice::Always => { - config.space_after_function_names = SpaceAfterFunctionNames::Always - } - SpaceAfterFunctionNamesChoice::Definitions => { - config.space_after_function_names = SpaceAfterFunctionNames::Definitions - } - SpaceAfterFunctionNamesChoice::Calls => { - config.space_after_function_names = SpaceAfterFunctionNames::Calls - } - SpaceAfterFunctionNamesChoice::Never => { - config.space_after_function_names = SpaceAfterFunctionNames::Never - } - } + config.space_after_function_names = match space_after_function_names { + SpaceAfterFunctionNamesChoice::Always => SpaceAfterFunctionNames::Always, + SpaceAfterFunctionNamesChoice::Definitions => SpaceAfterFunctionNames::Definitions, + SpaceAfterFunctionNamesChoice::Calls => SpaceAfterFunctionNames::Calls, + SpaceAfterFunctionNamesChoice::Never => SpaceAfterFunctionNames::Never, + }; } if let Ok(collapse_simple_statement) = properties.get::() { - match collapse_simple_statement { - CollapseSimpleStatementChoice::Never => { - config.collapse_simple_statement = CollapseSimpleStatement::Never - } - CollapseSimpleStatementChoice::FunctionOnly => { - config.collapse_simple_statement = CollapseSimpleStatement::FunctionOnly - } + config.collapse_simple_statement = match collapse_simple_statement { + CollapseSimpleStatementChoice::Never => CollapseSimpleStatement::Never, + CollapseSimpleStatementChoice::FunctionOnly => CollapseSimpleStatement::FunctionOnly, CollapseSimpleStatementChoice::ConditionalOnly => { - config.collapse_simple_statement = CollapseSimpleStatement::ConditionalOnly - } - CollapseSimpleStatementChoice::Always => { - config.collapse_simple_statement = CollapseSimpleStatement::Always + CollapseSimpleStatement::ConditionalOnly } - } + CollapseSimpleStatementChoice::Always => CollapseSimpleStatement::Always, + }; } if let Ok(sort_requires) = properties.get::() { - match sort_requires { - SortRequiresChoice::True => config.sort_requires = SortRequiresConfig { enabled: true }, - SortRequiresChoice::False => { - config.sort_requires = SortRequiresConfig { enabled: false } - } - } + config.sort_requires = match sort_requires { + SortRequiresChoice::True => SortRequiresConfig { enabled: true }, + SortRequiresChoice::False => SortRequiresConfig { enabled: false }, + }; } config From e8d6dc7c58602bc99fd2071ac45a287174fe54a0 Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Sat, 24 Jan 2026 22:07:49 +0800 Subject: [PATCH 3/4] changlog & test --- CHANGELOG.md | 1 + tests/inputs-editorconfig/.editorconfig | 1 + tests/inputs-editorconfig/global/tab-single.lua | 2 ++ tests/snapshots/test_editorconfig__global.snap | 3 +++ 4 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa68ef83..c1f94e39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- Fix `call_parentheses = Input` don't work in editorconfig ([#1057](https://github.com/JohnnyMorganz/StyLua/pull/1057)) ## [2.3.1] - 2025-11-01 diff --git a/tests/inputs-editorconfig/.editorconfig b/tests/inputs-editorconfig/.editorconfig index 9952276e..3356efdc 100644 --- a/tests/inputs-editorconfig/.editorconfig +++ b/tests/inputs-editorconfig/.editorconfig @@ -7,3 +7,4 @@ indent_size = 2 [global/tab-single.lua] indent_style = tab quote_type = single +call_parentheses = input diff --git a/tests/inputs-editorconfig/global/tab-single.lua b/tests/inputs-editorconfig/global/tab-single.lua index a55ef2ad..29a37201 100644 --- a/tests/inputs-editorconfig/global/tab-single.lua +++ b/tests/inputs-editorconfig/global/tab-single.lua @@ -3,3 +3,5 @@ local foo = { } local bar = "" + +unpack {} diff --git a/tests/snapshots/test_editorconfig__global.snap b/tests/snapshots/test_editorconfig__global.snap index 94a1ff46..21f35a79 100644 --- a/tests/snapshots/test_editorconfig__global.snap +++ b/tests/snapshots/test_editorconfig__global.snap @@ -1,5 +1,6 @@ --- source: tests/test_editorconfig.rs +assertion_line: 45 expression: "format(&contents, path.to_str().unwrap())" input_file: tests/inputs-editorconfig/global/tab-single.lua --- @@ -9,3 +10,5 @@ local foo = { local bar = '' +unpack {} + From 0e065c0b7a36c9cc3f59c307d1a66e7826f92c7d Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Sat, 24 Jan 2026 16:09:26 +0000 Subject: [PATCH 4/4] Tweak changelog and test --- CHANGELOG.md | 2 +- src/editorconfig.rs | 8 ++++++++ tests/inputs-editorconfig/.editorconfig | 1 - tests/inputs-editorconfig/global/tab-single.lua | 2 -- tests/snapshots/test_editorconfig__global.snap | 3 --- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d43c08c2..5324f64d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -- Fix `call_parentheses = Input` don't work in editorconfig ([#1057](https://github.com/JohnnyMorganz/StyLua/pull/1057)) ### Added - Added flag `--no-ignore-vcs` to continue formatting files listed in a `.gitignore` file, instead of skipping over them ([#895](https://github.com/JohnnyMorganz/StyLua/issues/895)) +- Support `call_parentheses = Input` in editorconfig ([#1057](https://github.com/JohnnyMorganz/StyLua/pull/1057)) ## [2.3.1] - 2025-11-01 diff --git a/src/editorconfig.rs b/src/editorconfig.rs index 20380192..e965cc44 100644 --- a/src/editorconfig.rs +++ b/src/editorconfig.rs @@ -314,6 +314,14 @@ mod tests { assert_eq!(config.call_parentheses, CallParenType::None); } + #[test] + fn test_call_parentheses_input() { + let mut properties = Properties::new(); + properties.insert_raw_for_key("call_parentheses", "Input"); + let config = Config::from(&properties); + assert_eq!(config.call_parentheses, CallParenType::Input); + } + #[test] fn test_space_after_function_names_always() { let mut properties = Properties::new(); diff --git a/tests/inputs-editorconfig/.editorconfig b/tests/inputs-editorconfig/.editorconfig index 3356efdc..9952276e 100644 --- a/tests/inputs-editorconfig/.editorconfig +++ b/tests/inputs-editorconfig/.editorconfig @@ -7,4 +7,3 @@ indent_size = 2 [global/tab-single.lua] indent_style = tab quote_type = single -call_parentheses = input diff --git a/tests/inputs-editorconfig/global/tab-single.lua b/tests/inputs-editorconfig/global/tab-single.lua index 29a37201..a55ef2ad 100644 --- a/tests/inputs-editorconfig/global/tab-single.lua +++ b/tests/inputs-editorconfig/global/tab-single.lua @@ -3,5 +3,3 @@ local foo = { } local bar = "" - -unpack {} diff --git a/tests/snapshots/test_editorconfig__global.snap b/tests/snapshots/test_editorconfig__global.snap index 21f35a79..94a1ff46 100644 --- a/tests/snapshots/test_editorconfig__global.snap +++ b/tests/snapshots/test_editorconfig__global.snap @@ -1,6 +1,5 @@ --- source: tests/test_editorconfig.rs -assertion_line: 45 expression: "format(&contents, path.to_str().unwrap())" input_file: tests/inputs-editorconfig/global/tab-single.lua --- @@ -10,5 +9,3 @@ local foo = { local bar = '' -unpack {} -