Clangd
is a language server that can work with many editors via a plugin, such as the clangd
plugin in VSCode. Generally, the plugin is used in couple with cmake
or other tools which can generate a compile-commands.json
file. It is a very good plugin, maybe better than the Microsoft's C/C++
plugin. However, there are still some annoying issues, especially on Windows. One of them is that clangd can't find the system headers, such as iostream
, fstream
. To solve this, one way is to manually specify the include directories of system headers in the clangd configure file.
A template is provided below:
CompileFlags:
Add:
- -IC:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/include
- -IC:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/winrt
- -IC:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/cppwinrt
- -IC:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/shared
- -IC:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt
- -IC:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/um
Diagnostics:
Suppress: ["pp_including_mainfile_in_preamble"]
ClangTidy:
Add:
[
boost-*,
bugprone-*,
clang-analyzer-*,
cppcoreguidelines-*,
modernize-*,
openmp-*,
performance-*,
readability-*,
]
Remove:
[
readability-braces-around-statements,
modernize-use-trailing-return-type,
cppcoreguidelines-special-member-functions,
cppcoreguidelines-non-private-member-variables-in-classes,
cppcoreguidelines-avoid-magic-numbers,
readability-magic-numbers,
readability-identifier-length,
readability-make-member-function-const,
bugprone-easily-swappable-parameters,
modernize-use-equals-default,
cppcoreguidelines-prefer-member-initializer
]
Index:
Background: Build