Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swayfmt: Support configuration file #6411

Open
sdankel opened this issue Aug 13, 2024 · 2 comments
Open

swayfmt: Support configuration file #6411

sdankel opened this issue Aug 13, 2024 · 2 comments
Labels
enhancement New feature or request formatter

Comments

@sdankel
Copy link
Member

sdankel commented Aug 13, 2024

Swayfmt is meant to be configurable. The task here is to:

  1. Support the parsing and loading of swayfmt.toml
  2. Implement the configuration options
    • It's okay if some only support the default option
    • Some of the options are already implemented
  3. Write tests for all options
  4. Update the docs stating which options are configurable.

The main reason it's not currently supported is that our small team hasn't had bandwidth to properly tests the options that are implemented.

The default swayfmt.toml:

max_width = 100
hard_tabs = false
tab_spaces = 4
newline_style = Auto
indent_style = Block
newline_threshold = 1
group_imports = Preserve
imports_granularity = Preserve
imports_indent = Block
reorder_imports = true
reorder_modules = true
reorder_impl_items = false
item_brace_style = SameLineWhere
blank_lines_upper_bound = 1
blank_lines_lower_bound = 0
empty_item_single_line = true
format_strings = false
hex_literal_case = Preserve
expr_brace_style = AlwaysSameLine
trailing_semicolon = true
space_before_colon = false
space_after_colon = false
type_combinator_layout = Wide
spaces_around_ranges = false
match_block_trailing_comma = false
match_arm_leading_pipe = Never
force_multiline_blocks = false
fn_args_layout = Tall
fn_single_line = false
heuristics_pref = Scaled
use_small_heuristics = true
field_alignment = Off
small_structures_single_line = true
wrap_comments = false
comment_width = 80
normalize_comments = false
@sdankel sdankel added enhancement New feature or request formatter labels Aug 13, 2024
@kayagokalp
Copy link
Member

kayagokalp commented Aug 19, 2024

My two piece on this would be not to allow it. This is purely a personal choice so nothing concrete behind it but even if someday we have the bandwidth to do so, I think we still shouldn't do it. I feel like formatter wise go made the correct choice over rust.

Also I believe that being a smart contract development language, conceptually gives us an extra opportunity to say that we are opinionated about standards, this can (and imo should) include the way sway programs supposed to look.

My problem with rustfmt is that the lack of standard look, rust itself enforces some strict rules on how you structure your code, the formatter should have followed a similar philosophy of being opinionated. Also I see bunch of weird diffs in different rust repos, due to different rustfmt configs

@sdankel
Copy link
Member Author

sdankel commented Sep 6, 2024

We decided as a team we do not want the formatter to be configurable. The next step is to remove the configuration code that currently exists in the formatter but isn't exposed in swayfmt/src/config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request formatter
Projects
None yet
Development

No branches or pull requests

2 participants