clang-format doesn't work out of the box
RunDevelopment opened this issue · 5 comments
I never worked with the formatter as is before and was very confused when VS Code just opened the terminal and outputted my formatted code.
I then found that you have to give clang-format
the -i
arg for it to work.
Please document this as I expect the default formatter of this extension to just work.
Alternatively, the extension could just add -i
to the list of args automatically. If that takes away to much control, it could set the args to -i
if no arguments are specified. With both solutions, the extension will work out of the box.
Hello @RunDevelopment!
Actually the extension adds -i
to the list of args already.
Could you provide additional information, so I can reproduce the behaviour you are describing?
- Do you use "Format Document" action from the context menu in VS Code?
- Are you trying to format
*.cl
file? - Do you have C++ extension installed in VS Code?
- Did you override settings
opencl.formatting.name
andopencl.formatting.options
? - What operating system are you using?
Thank you for the quick response!
- I use
Alt + Shift + F
which calls the "Format Document" action, so yes. - Yes.
- No. I have clang (and by extension) clang-format installed separately. The directory of clang-format is included in my Path variable. clang-format itself is called.
- No. But when I override
opencl.formatting.options
with"opencl.formatting.options": ["-i"]
, it works. - Win 10 64bit Version 10.0.18362 Build 18362
I see. Point 2 is the cause of the issue.
Well, if no args are provided, it should probably still set the -i
flag.
The extension requires ms-vscode.cpptools
to be installed as well. In that case in-place formatting will be done out of box.
Argument -i
might not work for other formatters. In the next release I'll set -i
for custom formatter if it is a clang-formatter
.
The extension requires
ms-vscode.cpptools
to be installed as well.
Sorry, my bad. I thought this extension only needs ms-vscode.cpptools
because of clang-format
.
Thank you for your help!