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

#1009, #566: Use clang-format as the default sketch formatter. #1019

Merged
merged 1 commit into from
Jun 7, 2022

Conversation

kittaakos
Copy link
Contributor

@kittaakos kittaakos commented Jun 2, 2022

Motivation

Use clang-format as the default sketch file formatter. It's faster and does not require a running LS.

Change description

  • Bumped clangd to 14.0.0,

Other information

Closes #1009
Closes #566

For the reviewers:

  • Please open dev tools for verification. Formatting $URI [Range: $RANGE] should be logged when the clang-format-ter is used instead of the LS.
  • The formatter should work if the LS is not running.
    Screenshot 2022-06-02 154556

(👆 The Format Document and Format Selection context menu items are available, although the LS is not running.)

  • The formatter should work even if there is a whitespace in the sketch name (sketch with spaces.ino) or in the IDE path (/path/to/segment with spaces/arduino-ide).
  • Make sure the beginning and the end of the document are formatted (this should verify the correctness of document range calculation).
  • It should be possible to add a custom .clang-format file. The precedence is the following:
    • current sketch,
    • ~/.arduinoIDE/.clang-format,
    • directories#data/.clang-format, or
    • falls back to default formatter styles.
  • It should be possible to select multiple ranges, not only the entire document:
format.mp4

Reviewer checklist

  • PR addresses a single concern.
  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • PR title and description are properly filled.
  • Docs have been added / updated (for bug fixes / features)

Copy link

@ubidefeo ubidefeo left a comment

Choose a reason for hiding this comment

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

works well but in this build I still have double tabs per file and full path added (see screenshot)

CleanShot 2022-06-06 at 10 01 47@2x

 - Bumped `clangd` to `14.0.0`,
 - Can use `.clang-format` from:
   - current sketch folder,
   - `~/.arduinoIDE/.clang-format`,
   - `directories#data/.clang-format`, or
   - falls back to default formatter styles.

Closes #1009
Closes #566

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
@kittaakos kittaakos merged commit a59e0da into main Jun 7, 2022
@kittaakos kittaakos deleted the #1009-signed branch June 7, 2022 08:51
@per1234 per1234 linked an issue Jun 8, 2022 that may be closed by this pull request
3 tasks
@per1234 per1234 linked an issue Jun 8, 2022 that may be closed by this pull request
@per1234 per1234 linked an issue Jun 8, 2022 that may be closed by this pull request
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Jun 11, 2022
@per1234 per1234 linked an issue Jun 11, 2022 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
4 participants