3 Provides C/C++ language IDE features for VS Code using [clangd](https://clang.llvm.org/extra/clangd.html):
6 - compile errors and warnings
7 - go-to-definition and cross references
16 `clangd` is a language server that must be installed separately, see
17 [getting started](https://clang.llvm.org/extra/clangd/Installation.html#installing-clangd).
18 The vscode-clangd extension will look for `clangd` on your PATH (you can change
19 this in the settings).
23 clangd is based on the clang C++ compiler, and understands even complex C++
24 code. However, you must tell clangd how your project is built (compile flags).
25 [A `compile_commands.json` file](http://clang.llvm.org/docs/JSONCompilationDatabase.html)
26 can usually be generated by your build system
27 (e.g. by setting `-DCMAKE_EXPORT_COMPILE_COMMANDS=1` when building with CMake,
29 [many other tools](https://sarcasm.github.io/notes/dev/compilation-database.html)).
31 It should live at the top of your source tree: symlink or copy it there.
37 Suggestions will appear as you type names, or after `.` or `->`.
38 Because clangd uses a full C++ parser, code completion has access to precise
41 
43 ### Errors, warnings, and clang-tidy
45 Code errors are shown as you type (both as red squiggle underlines, and in the
46 "Problems" panel). These are the same as produced by the clang compiler, and
47 suggested fixes can automatically be applied.
49 
51 Most clang-tidy checks are supported (these can be enabled using a [.clang-tidy
52 file](https://clang.llvm.org/extra/clang-tidy/)).
56 Go-to-definition and find-references work across your code, using a project-wide
59 
61 Press `Ctrl-P #` to quickly navigate to a symbol by name.
63 ### Include management
65 Code completion works across your codebase and adds `#include` directives where
66 needed. The `•` shows includes that will be inserted.
68 clangd can also suggest inserting missing #includes, where they cause errors.
70 
74 clangd uses the `clang-format` engine. You can format a file or the selection.
75 When "Format on Type" is enabled in the settings, pressing enter will cause
76 clangd to format the old line and semantically reindent.
78 
80 The style used for formatting (and certain other operations) is controlled by
81 the .clang-format file is controlled by the project's
82 [.clang-format file](https://clang.llvm.org/docs/ClangFormatStyleOptions.html).
86 clangd supports some local refactorings. When you select an expression or
87 declaration, the lightbulb menu appears and you can choose a code action.
89 
91 Current refactorings include:
92 - extract variable/function
93 - expand `auto` types and macros
95 - rename (bound to `<F2>`, rather than a contextual code action)
99 clangd and vscode-clangd are part of the [LLVM project](https://llvm.org).
101 If you'd like to help out, reach out to clangd-dev@lists.llvm.org.
103 If you've found a bug, please file at https://github.com/clangd/clangd/issues.