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.

clang-format and clangd

See original GitHub issue

Steps to Reproduce:

  1. I installed clangd extension for intellisense
  2. reformat the code file, the code format it not visual code style, maybe become llvm style.
  3. I create .clang-format file in the project root. run the command clang-format -style=Microsoft -dump-config > .clang-format
  4. reformat the code, code style not become Microsoft style

Logs: I just reformat the engine.h file

I[09:08:12.893] <-- textDocument/codeAction(15)
I[09:08:12.894] --> reply:textDocument/codeAction(15) 1 ms
I[09:08:12.895] --> textDocument/clangd.fileStatus
I[09:08:13.646] <-- textDocument/formatting(16)
e:\Turbo\.clang-format:1:4: error: Got empty plain scalar
��-I[09:08:13.650] --> reply:textDocument/formatting(16) 3 ms
I[09:08:13.689] <-- textDocument/didChange
I[09:08:13.690] --> textDocument/clangd.fileStatus
I[09:08:13.746] ASTWorker building file e:\Turbo\engine\include\TEngine.h version 2 with command inferred from E:/Turbo/engine/src/TEngine.cpp
[E:/Turbo/build/engine/src]
"F:\\llvm-mingw-20211002-msvcrt-x86_64\\bin\\g++.exe" --driver-mode=g++ -IF:/VulkanSDK/1.2.135.0/Include -IE:/Turbo/engine/src/../include -g -c -x c++-header -std=gnu++14 "-resource-dir=F:\\LLVM\\lib\\clang\\13.0.1" -- "e:\\Turbo\\engine\\include\\TEngine.h"
I[09:08:13.756] --> textDocument/clangd.fileStatus
I[09:08:13.756] --> textDocument/clangd.fileStatus
I[09:08:13.927] <-- textDocument/codeAction(17)
I[09:08:13.927] --> textDocument/clangd.fileStatus
e:\Turbo\.clang-format:1:4: error: Got empty plain scalar
��-I[09:08:13.972] --> reply:textDocument/codeAction(17) 44 ms
I[09:08:13.972] --> textDocument/clangd.fileStatus
I[09:08:14.700] --> workspace/semanticTokens/refresh(3)
I[09:08:14.700] --> textDocument/clangd.fileStatus
I[09:08:14.701] <-- reply(3)
I[09:08:14.706] <-- textDocument/semanticTokens/full/delta(18)
I[09:08:14.706] <-- textDocument/semanticTokens/full/delta(19)
I[09:08:14.706] --> reply:textDocument/semanticTokens/full/delta(18) 0 ms
I[09:08:14.706] --> textDocument/clangd.fileStatus
e:\Turbo\.clang-format:1:4: error: Got empty plain scalar
��-I[09:08:14.743] --> textDocument/publishDiagnostics
I[09:08:14.743] --> reply:textDocument/semanticTokens/full/delta(19) 36 ms
I[09:08:14.743] --> textDocument/clangd.fileStatus
I[09:08:14.878] <-- textDocument/documentLink(20)
I[09:08:14.878] --> reply:textDocument/documentLink(20) 0 ms
I[09:08:14.878] --> textDocument/clangd.fileStatus
I[09:08:15.090] <-- textDocument/documentSymbol(21)
I[09:08:15.090] --> reply:textDocument/documentSymbol(21) 0 ms
I[09:08:15.091] --> textDocument/clangd.fileStatus

System information Clangd version (from the log, or clangd --version):

clangd version 13.0.1
Features: windows
Platform: x86_64-pc-windows-msvc

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
FuXiiicommented, Mar 24, 2022

image

Yes! you are right. Thank you very much~ 😄

0reactions
HighCommander4commented, Mar 24, 2022

I searched around for this error, and based on answers like this one it seems to me that this is a Windows issue related to the encoding of the text file.

Try copy-and-pasting the contents from the github comment on this page into a fresh text file, or using an editor like Notepad++ to explicitly save the file with utf-8 encoding, that should hopefully fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clang-Format Style Options — Clang 16.0.0git documentation
clang-format supports two ways to provide custom style options: directly specify style configuration in the -style= command line option or use -style=file and ......
Read more >
How can I set .clang-format globally? · Issue #39 - GitHub
I'm struggling with this problem for hours. As far as I know, clangd doesn't have -style option unlike clang-format and there's no way...
Read more >
clangd - Visual Studio Marketplace
clangd uses the clang-format engine. You can format a file or the selection. When "Format on Type" is enabled in the settings, pressing...
Read more >
vscode + clangd extension: formatting ignores .clang-format file
Apparently Apple Clang 14 does not support all the formatting options that LLVM Clang 14 does. Clangd failed to parse the .clang-format file ......
Read more >
Using Clang-Format | JetBrains Rider Documentation
Clang-Format is a widely-used C++ code formatter. It provides an option to define code style options in YAML-formatted files — named ...
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