After enabling this feature I am not able to use clang-format to format files
See original GitHub issueIssue Type: Bug
Enabling this extension stops VS Code from formatting my files when using clang-format.
It works perfectly fine when using Intellisense. It also works fine when enabling the extension for the first time in one VS Code session. But if the extension is enabled and I restart VS code then formatting stops working. There is a quick status message at the bottom saying extension c/c++ cannot format .....myFileName...
The C/C++ extension doesn’t output any logs in the output tab. I assume that has to do with the fact that Intellisense is disabled after clangd is enabled.
Clangd doesn’t output any additional logs in the output tab when formating a file fails.
Extension version: 0.1.11 VS Code version: Code 1.56.2 (054a9295330880ed74ceaedda236253b4f39a335, 2021-05-12T16:45:26.313Z) OS version: Linux x64 5.12.5-arch1-1
System Info
Item | Value |
---|---|
CPUs | 11th Gen Intel® Core™ i7-1185G7 @ 3.00GHz (8 x 4408) |
GPU Status | 2d_canvas: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: disabled_off opengl: enabled_on rasterization: disabled_software skia_renderer: enabled_on video_decode: disabled_software vulkan: disabled_off webgl: enabled webgl2: enabled |
Load (avg) | 1, 1, 1 |
Memory (System) | 31.06GB (19.39GB free) |
Process Argv | –no-sandbox --unity-launch --crash-reporter-id 87fed376-385e-4b70-a6e7-f62fe0f386e3 |
Screen Reader | no |
VM | 0% |
DESKTOP_SESSION | gnome |
XDG_CURRENT_DESKTOP | GNOME |
XDG_SESSION_DESKTOP | gnome |
XDG_SESSION_TYPE | wayland |
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
This one’s not clangd’s fault. Think you’ve got a setting in your config something like
which tells it to use cpptools (the MS C/C++ extension) for code formatting. As you surmise, for some reason cpptools doesn’t do code formatting if its intellisense is disabled (I even raised a bug for it the other day!). If you remove that setting, clangd will do the formatting using its own copy of clang-format.
That’s going to be client-dependent, but e.g. with VSCode, you can install the xaver.clang-format extension and configure that to be your default formatter (that extension in turn has a setting to point it to a
clang-format
executable).