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

try new stricter formatting #476

Merged
merged 3 commits into from
Feb 16, 2024

Conversation

Pascal-Delange
Copy link
Contributor

@Pascal-Delange Pascal-Delange commented Feb 15, 2024

  • commit 1: general gofumpt rules (no brainer IMO)
  • commit 2: more debatable rule on max line length (but I'm very in favor of it)
  • commit 3: add Thomas' settings file

See discussion in mvdan/gofumpt#2 on max length formatting. It works with a set max line length of 120 chars and some heuristics to produce reasonable looking code. You can always indent it more manually.
To be clear: I don't think it always results in the single most optimal indentation, which can be achieved manually where needed, but at least it forces something (and does it by being conservative rather than aggressive, so as to not break anyone's manual indentation).
It's an experimental flag so run it in terminal with GOFUMPT_SPLIT_LONG_LINES=on gofumpt -l -w .

and https://github.com/mvdan/gofumpt?tab=readme-ov-file for gofumpt generally

@Pascal-Delange Pascal-Delange force-pushed the pascal/test-gofumpt-with-max-line-length branch from d94bb08 to 68c2b70 Compare February 15, 2024 16:39
@Pascal-Delange Pascal-Delange force-pushed the pascal/test-gofumpt-with-max-line-length branch from 7165e7f to c96148a Compare February 15, 2024 16:43
@Pascal-Delange Pascal-Delange marked this pull request as ready for review February 15, 2024 16:45
Copy link
Contributor

@balzdur balzdur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no strong opinion on lines length.
I really like having a better formatter than the Go standard one (comming from Prettier world, it's not enough work done for me ahha)

What I still wonder is do this format on save whith the current settings ? IIUC, it's handled by gopls + VSCode integration of gopls is that right ?

@Pascal-Delange
Copy link
Contributor Author

Yep I'm not a line length nazi either, but too much is too much (and ~120 is reasonable, I don't want to horizontally scroll my code).

I still prefer "all params in one line or all on split lines", but I can still do that manually (wasn't motivated to apply it manually everywhere though).

It will apply this format on save with the changes made to settings.json (gopls will choose the formatter from the language server and use gofumpt as configured)

@Pascal-Delange Pascal-Delange merged commit 2f3c7d8 into main Feb 16, 2024
3 checks passed
@Pascal-Delange Pascal-Delange deleted the pascal/test-gofumpt-with-max-line-length branch February 16, 2024 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants