Features

Here is what clangd can do for you. Screenshots below show VSCode; the available features and UI depend on the editor.

Errors and warnings

clangd runs the clang compiler on your code as you type, and shows errors and warnings in-place. Some errors are suppressed: diagnostics that require expanding templates in headers are disabled for performance reasons.

Screenshot

Demonstration of errors

Fixes in errors and warnings

The compiler can suggest fixes for many common problems automatically, and clangd can update the code for you.

Animated demo

Applying a fix suggested by the compiler

(New in v9) If a missing symbol was seen in a file you’ve edited recently, clangd will suggest inserting it.

clang-tidy checks

(New in v9) clangd embeds clang-tidy which provides extra hints about code problems: bug-prone patterns, performance traps, and style issues.

Animated demo

Applying a fix suggested by the compiler

clangd respects your project’s .clang-tidy file which controls the checks to run. Not all checks work within clangd. You must pass the -clang-tidy flag to enable this feature.

Code completion

You’ll see suggestions as you type based on what methods, variables, etc are available in this context.

Screenshot

Code completion demonstration

Abbreviating words may help you find the right result faster. If you type in camelCase but the function you’re looking for is snake_case, that’s OK.

Insertion of namespace qualifiers and includes

(New in v8) clangd will sometimes suggest results from other files and namespaces. In this case the correct qualifier and #include directive will be inserted.

Animated demo

Code completion inserts namespace qualifiers

Signature help

Some editors will show you the parameters of the function you’re calling, as you fill them in.

Animated demo

Demonstration of the signature help feature

Cross-references

The following features let you navigate your codebase.

If there is no project-wide index, cross-references work across the files you have opened.

(New in v9) clangd will also automatically index your whole project.

Find definition/declaration

Jump to the definition or declaration of a symbol under the cursor.

Animated demo

Demonstration of the "Go to definition" feature

(New in v9) Some editors only expose “find definition”; use “find definition” on the definition to jump to the declaration.

“Find definition” also works on #include lines, to jump to the included file.

Find references

Show all references to a symbol under the cursor.

Animated demo

Demonstration of the "Find all references" feature

Some editors will automatically highlight local references to the selected symbol as you move around a file.

Formatting

clangd embeds clang-format, which can reformat your code: fixing indentation, breaking lines, and reflowing comments.

Animated demo

Formatting selected code

clangd respects your project’s .clang-format file which controls styling options.

Format-as-you-type is experimental and doesn’t work well yet.

Complete list of features

Here is a list of features that could be useful for editors, together with the implementation status in clangd, and specification in the Language Server Protocol.

It is not clear whether or not some of the features mentioned below should be a part of the Language Server Protocol; those features might be eventually developed outside clangd or become clangd extensions to LSP.

C/C++ Editor feature LSP Clangd
Formatting Yes Yes
Completion Yes Yes
Diagnostics Yes Yes
Fix-its Yes Yes
Go to Definition Yes Yes
Signature Help Yes Yes
Document Highlights Yes Yes
Rename Yes Yes
Source hover Yes Yes
Find References Yes Yes
Document Symbols Yes Yes
Workspace Symbols Yes Yes
Code Lens Yes No
Code folding Yes No
Extract Local Variable Yes No
Extract Function/Method Yes No
Quick Assist Yes No
Hide Method Yes No
Implement Method Yes No
Gen. Getters/Setters Yes No
Syntax and Semantic Coloring Proposed [1] Yes
Call hierarchy Proposed [2] No
Type hierarchy Proposed [3] Yes
Organize Includes Yes No
[1]https://github.com/microsoft/language-server-protocol/issues/18
[2]https://github.com/microsoft/language-server-protocol/issues/468
[3]https://github.com/microsoft/language-server-protocol/issues/136