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/2] 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/2] 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