Skip to content
New issue

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

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

Already on GitHub? # to your account

Disable vscode autoformatting #229

Closed
gnprice opened this issue Jul 19, 2023 · 2 comments · Fixed by #230
Closed

Disable vscode autoformatting #229

gnprice opened this issue Jul 19, 2023 · 2 comments · Fixed by #230
Assignees
Labels
a-tools Our own development tooling, scripts, and infrastructure
Milestone

Comments

@gnprice
Copy link
Member

gnprice commented Jul 19, 2023

We've had a couple of contributors who use Visual Studio Code, and were frustrated by its eagerness to reformat entire files:

It should be possible to supply project-level config to VS Code to tell it not to do that, and we should put that config in the repo.

The PR #155 included a draft of such a config, which can be a starting point.

@gnprice gnprice added the a-tools Our own development tooling, scripts, and infrastructure label Jul 19, 2023
@gnprice gnprice added this to the Alpha milestone Jul 19, 2023
@gnprice gnprice self-assigned this Jul 19, 2023
@onli
Copy link

onli commented Jul 19, 2023

A suggestion: The ideal solution would be not to disable the formating completely, but to let that IDE autoformat it in an acceptable way. I'm actually surprised that there is a format conflict here, doesn't VSCode with the flutter plugin just call dartfmt, and wouldn't dartfmts default be the best code style for this flutter project?

@gnprice
Copy link
Member Author

gnprice commented Jul 19, 2023

Yeah. We don't use dartfmt, and instead use a style similar to what's in the Flutter repo itself:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#formatting

Our experience has been that

  • there are several recurring ways in which dartfmt tends to make the code harder to read than it would be if formatted better;
  • and at least for me, when using dartfmt / dart format, it hasn't felt to me like it means not thinking about formatting, more like doing different thinking about formatting.

Discussion with more details here:
https://chat.zulip.org/#narrow/stream/48-mobile/topic/Dart.20formatting/near/1585603
There's also a bit further context in:

The Flutter folks would like to use autoformatting too, and have had discussions for years with the Dart folks about making dartfmt work well for the Flutter style. I recently saw a mention that there might be progress happening on that, which would be great.

gnprice added a commit to gnprice/zulip-flutter that referenced this issue Jul 19, 2023
The details here are largely borrowed from the Flutter repo,
and in particular the subtleties most recently added there:
  flutter/flutter#122758

This config does the job in my testing.

Note that it doesn't affect any of the things the editor does to
simply augment your typing: adding indentation when you hit enter,
adding a close-paren when you type an open-parent, and so on.
Those are perfectly fine -- most of all because they only affect the
code you actually intended to edit, but also because they generally
get things right -- and continue operating as usual.

Fixes: zulip#229
chrisbobbe pushed a commit that referenced this issue Jul 20, 2023
The details here are largely borrowed from the Flutter repo,
and in particular the subtleties most recently added there:
  flutter/flutter#122758

This config does the job in my testing.

Note that it doesn't affect any of the things the editor does to
simply augment your typing: adding indentation when you hit enter,
adding a close-paren when you type an open-parent, and so on.
Those are perfectly fine -- most of all because they only affect the
code you actually intended to edit, but also because they generally
get things right -- and continue operating as usual.

Fixes: #229
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
a-tools Our own development tooling, scripts, and infrastructure
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants