Skip to content

Support global custom formatter configuration #566

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

Closed
per1234 opened this issue Oct 21, 2021 · 0 comments · Fixed by #1019
Closed

Support global custom formatter configuration #566

per1234 opened this issue Oct 21, 2021 · 0 comments · Fixed by #1019
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: language server Related to the Arduino Language Server type: enhancement Proposed improvement

Comments

@per1234
Copy link
Contributor

per1234 commented Oct 21, 2021

Code formatting style preferences vary and are often strongly held. For this reason, it's important for development tools to allow customization of the formatter tool.

This is already possible on a per-project basis by adding a .clang-format ClangFormat configuration file to the root of the sketch folder. That will be the best approach for collaborative projects, so that the configuration is distributed to all contributors along with the project, ensuring their contributions will be consistent with the project's established code style.

However, users also use the Arduino IDE for development of many solo projects. For that use case, it will not be convenient to maintain a copy of the formatter configuration file inside every sketch. Better will be to place a single configuration file in a standardized location, which will be applied to all sketches that don't contain a local configuration file. This idea was discussed during the process of integrating the standardized Arduino ClangFormat configuration to the Arduino Language Server:
arduino/arduino-language-server#69 (comment)
The capability was added to Arduino Language Server at that time in the form of a format-conf-path flag, through which the path to the global configuration file may be passed:
https://github.com/arduino/arduino-language-server/blob/e453c5fbd059bae673bb21d028f5ca8e690744be/main.go#L35

It doesn't appear that Arduino IDE has been configured to use that capability yet though.

There may be a decision regarding where the file should be located:

  • ~/.arduinoIDE/.clang-format
  • <directories.data>/.clang-format (e.g., ~/.arduino15/.clang-format)

The Java IDE has support for placing its formatter.conf file in directories.data, so the ability to set a global custom formatter configuration is a matter of feature parity.

Customizing the formatting style is something only advanced users will be interested in, so I don't see any need for GUI changes related to this work.


Fixes #94
Fixes #439
Part of best efforts to mitigate #42

@per1234 per1234 added topic: code Related to content of the project itself topic: language server Related to the Arduino Language Server type: enhancement Proposed improvement labels Oct 21, 2021
@kittaakos kittaakos self-assigned this Jun 1, 2022
kittaakos pushed a commit to kittaakos/arduino-ide that referenced this issue Jun 2, 2022
 - 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 arduino#1009
Closes arduino#566

Signed-off-by: Akos Kitta <[email protected]>
kittaakos pushed a commit that referenced this issue Jun 2, 2022
 - 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 <[email protected]>
kittaakos pushed a commit that referenced this issue Jun 7, 2022
 - 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 <[email protected]>
kittaakos pushed a commit that referenced this issue Jun 7, 2022
 - 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 <[email protected]>
@per1234 per1234 added the conclusion: resolved Issue was resolved label Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: language server Related to the Arduino Language Server type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants