The auto format from arduino ide 2 beta 7 puts brace behind function definition, while I like to have the braces straight under each other
Is there any way I can change this or can this preference be added in a next beta?
pert
May 18, 2021, 8:29am
2
Hi @natanassies you can learn about the intended system for customizing the auto format configuration of Arduino IDE 2.x here:
arduino:main
← arduino:do-not-consider-preprocessed-section
opened 10:55PM - 22 Feb 21 UTC
Should fix some auto-format issues.
Maybe this should be done on the sketchma… pper side?
In addition to a similar capability for defining a custom global configuration, as was possible with the classic Arduino IDE, you will also have the new capability to define formatting configurations on a per-sketch basis by adding a .clang-format configuration file to the sketch folder. This could be very useful to ensure consistent code style when collaborating on a project with multiple people, who might have different global configurations.
You can learn about the ClangFormat configuration options here:
https://clang.llvm.org/docs/ClangFormatStyleOptions.html
The last I checked it seemed like the full configurability was not implemented yet, but that was some time ago so maybe it has been finished since. Either way, you can see the roadmap now, and that there will be happy times for lovers of broken braces somewhere down the road.
system
Closed
September 15, 2021, 8:29am
3
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.
.clang-format
files in the sketch root folder are now supported.
Some of the work is done for global custom formatter configuration support, but it is not finished yet. That is being tracked here:
opened 10:27AM - 21 Oct 21 UTC
closed 08:51AM - 07 Jun 22 UTC
type: enhancement
conclusion: resolved
topic: code
topic: language server
Code formatting style preferences vary and are often strongly held. For this rea… son, 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](https://releases.llvm.org/11.0.1/tools/clang/docs/ClangFormatStyleOptions.html) 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:
https://github.com/arduino/arduino-language-server/pull/69#discussion_r581173768
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](https://github.com/arduino/Arduino/blob/master/build/shared/lib/formatter.conf) 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 https://github.com/arduino/arduino-ide/issues/94
Fixes https://github.com/arduino/arduino-ide/issues/439
Part of best efforts to mitigate https://github.com/arduino/arduino-ide/issues/42