This is too complicated for me
. Sorry, I'm not going to write my own IDE editor. I can't edit the editors (IDE) either. Download, use (or not use) it.
It can't - let it stay that way. It's my problem, we'll get used as it is
.
This is too complicated for me
. Sorry, I'm not going to write my own IDE editor. I can't edit the editors (IDE) either. Download, use (or not use) it.
It can't - let it stay that way. It's my problem, we'll get used as it is
.
Did it change the behaviour on the line in your ino/cpp/h file that I indicated? If not, the .clang-format file contains an error or is not found.
You did not mention your operating system, I still wanted to add that others can indicate where the .clang-format file should be in a Mac or in Linux.
This is the file with the suggested change. Extract it to the earlier given directory
.clang-format.rockn.zip (1.9 KB)
That is going to be a tough one. The autoformatter is highly configurable but there seem to be some things that it insists on modifying. There are also settings that have an effect on others; e.g. the change that I suggested for your use case affects my standard settings.
The chances of them being fatal are near zero. The only thing that can happen (as to what I have seen) is that it will not apply any formatting.
Note:
I posted this while some other replies came in (e.g. your screenshots).
Win 10 Pro x64.
File .clang-format in folder: not change, Auto Format not work.
Delete file, restart IDE: Auto Format work like v2.0.1.
And even if it did, I wouldn't want to copy In folder another file outside of the project. I have > 5000 folders of different projects on disks
I'm stick to: no IDE v2.0.1. And waiting for another version.
The bigger problem of is the slow startup!
(think about the slow starting: Arduino IDE have anything with facebook (connections, frames, clouds ...) ? It's blocked from my router).
In your "after V2.0.1", I think that I can see that the change did not take effect. If you have a .clang-format, please zip it and attach it. I might want to have a look at it; note that I'm not a specialist on it.
I do not understand.
The .clang-format in C:\Users\yourUsername\.arduinoIDE is global and affects all sketches / sjetch files (ino/cpp/h etc); that's the only place, nothing that you can do about it
The alternative is to have one .clang-format in every sketch directory (not in the sketchbook directory); unfortunately the Arduino IDE does not support a .clang-format in the sketchbook directory.
I start it up, go and have a
and by the time I'm back it has started. I admit that it's not terribly fast but if I compare it to 1.8.x it's kind of equal; 1.8.x goes through all the installed libraries and if you have a lot of them it's also slow and I think that 2.0 actually does it in the background.
action 1: File .clang-format in folder: not change, Auto Format not work.
action 2: Delete file, restart IDE: Auto Format work like v2.0.1.
(Sorry for my english, I'm not expressing myself correctly, I use 90% Google Translate BG->EN.)
When you start the IDE from the command line, logs are printed to the terminal.
I have found that the error messages printed there when you attempt an auto format in the IDE with an invalid configuration in place are very useful for troubleshooting.
I'll provide instructions for starting the IDE from the command line terminal:
C:\Program Files\Arduino IDE or C:\Users\<user name>\AppData\Local\Programs\Arduino IDE).& ".\Arduino IDE"
Now examine the content toward the end of the logs.
This is what I see there after installing the configuration file @sterretje provided in the .clang-format.rockn.zip file attached in the previous reply:
root INFO Formatting file:///c%3A/Users/per/Documents/Arduino/Bar/Bar.ino [Range: {"startLineNumber":1,"startColumn":1,"endLineNumber":18,"endColumn":15}]
root ERROR Error: Error executing "C:\ide 2\tip\151-2.0.1\resources\app\node_modules\arduino-ide-extension\build\clang-format.exe" -style=file:"\Users\per\.arduinoIDE\.clang-format": \Users\per\.arduinoIDE\.clang-format:166:31: error: invalid number
SpacesBeforeTrailingComments: -1
^~
Error reading \Users\per\.arduinoIDE\.clang-format: invalid argument
at ChildProcess.<anonymous> (C:\ide 2\tip\151-2.0.1\resources\app\node_modules\arduino-ide-extension\lib\node\exec-util.js:53:31)
at ChildProcess.emit (node:events:394:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
root ERROR Request format failed with error: Error executing "C:\ide 2\tip\151-2.0.1\resources\app\node_modules\arduino-ide-extension\build\clang-format.exe" -style=file:"\Users\per\.arduinoIDE\.clang-format": \Users\per\.arduinoIDE\.clang-format:166:31: error: invalid number
SpacesBeforeTrailingComments: -1
^~
Error reading \Users\per\.arduinoIDE\.clang-format: invalid argument
root ERROR Failed to execute command:
OK, that explains why it did not change the original file when I tried it as no changes are applied. It also explains why adding the -1 to my usual file caused the autoformat to stop working.
Thanks
BTW, I could find it back in the log files
That is also a valid approach to troubleshooting the ClangFormat configuration. I personally prefer the terminal output because it is printed in real time so I can see the specific logs that are printed as I am performing an operation (e.g., auto format) in the IDE. But some might find the log files more convenient.
For the benefit of any interested parties, I'll provide the location of the log files automatically generated by Arduino IDE:
%APPDATA%\Arduino IDE\
(e.g., C:\Users\<user name>\AppData\Roaming\Arduino IDE\)
If XDG_CONFIG_HOME is set:
${XDG_CONFIG_HOME}/Arduino IDE
Otherwise:
~/.config/Arduino IDE
~/Library/Logs/Arduino IDE/
Here's my solution to disable comment formatting in Arduino IDE v2.0.4:
.clang-format in your project directory (where the .ino file is located).AlignTrailingComments: false
ColumnLimit: 200
.clang-format file.Raofin, thanks!
But I would like auto-formatting to work like in IDE v1, not no auto-formatting.
Auto-formatting even from Arduino IDE I use for final auto-formatting from other compilers, for other MCU, text looks perfect.
Nothing. I'm partially (and temporarily) stuck on IDE v1.8.19.
To help anyone else who is looking for the answer to preventing autoformat altering white-space formatting placed amongst code in IDE v2.x:
Place a '.clang-format' file (see below) which the has been altered to disable "SpacesBeforeTrailingComments:" by changing its value to -1 to either:
a. every sketch folder where you do not want the formatting altering
or:
b. to make the change affect formatting of all sketches, add it to the C:\Users\yourUsername\.arduinoIDE folder.
It is true that this will prevent the alteration of whitespace formatting. However, that is only because setting the invalid value breaks the Arduino IDE's "Auto Format" feature completely, as was already explained in this thread.
If for some strange reason someone does wish to completely disable the feature, it would be more appropriate to do that by adding this valid line to a custom .clang-format file:
DisableFormat: true
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.