question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After enabling this feature I am not able to use clang-format to format files

See original GitHub issue

Issue 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:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rjra100commented, May 26, 2021

This one’s not clangd’s fault. Think you’ve got a setting in your config something like

    "[cpp]": {
        "editor.defaultFormatter": "ms-vscode.cpptools"
    },

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.

0reactions
HighCommander4commented, Jun 7, 2021

What is the best way to use clangd as a language server and another clang-format for formatting? Is that possible?

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).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clang-format not apparently working - Visual Studio Feedback
I enabled it in Settings/C++/Formatting, and have the .clang-format file (again, plugin version works), and no matter how I change the document, ...
Read more >
Default working .clang-format file for Visual Studio
First, you need to check Tools->Options->Text Editor->C/C++->Formatting->General->Enable ClangFormat support . You could also Use custom clang- ...
Read more >
ClangFormat Support in Visual Studio 2017 - C++ Team Blog
You can change this to have it only use ClangFormat for explicit Format Document and Format Selection commands by choosing Run ClangFormat only ......
Read more >
Clang-Format Style Options — Clang 16.0.0git documentation
When using -style=file , clang-format for each input file will try to find the .clang-format file located in the closest parent directory of...
Read more >
clang-format for Rider not working properly
Hi, I am trying out Rider for Unreal Engine, and one of the most important aspects for me is to be able to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found