llvm-project/clang-tools-extra/clangd/clients/clangd-vscode
Haojian Wu f8c17fe111 [clangd] fixes semantic highlighting test
Summary: fixes https://github.com/clangd/clangd/issues/176

Patch by liu hui!

Reviewers: ilya-biryukov, hokein, sammccall

Reviewed By: hokein

Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D70078
2019-11-11 16:47:44 +01:00
..
.vscode
doc-assets [clangd] Update clangd-vscode docs to be more user-focused. 2019-09-09 11:34:01 +00:00
src [clangd] Fixes colon escaping on Windows 2019-11-11 09:21:25 +01:00
test [clangd] fixes semantic highlighting test 2019-11-11 16:47:44 +01:00
.gitignore [clangd] Add .vscode-test to .gitignore. 2019-08-30 09:06:18 +00:00
.vscodeignore
DEVELOPING.md [clangd][vscode] Add npm helper commands to package/release the extension. 2019-09-26 14:04:52 +00:00
LICENSE Update year in license files 2019-01-15 15:10:32 +00:00
README.md [clangd] some tweaks on the vscode readme, NFC 2019-09-10 08:07:12 +00:00
package-lock.json [clangd] Fixes colon escaping on Windows 2019-11-11 09:21:25 +01:00
package.json [clangd] Fixes colon escaping on Windows 2019-11-11 09:21:25 +01:00
tsconfig.json
vsc-extension-quickstart.md

README.md

vscode-clangd

Provides C/C++ language IDE features for VS Code using clangd:

  • code completion
  • compile errors and warnings
  • go-to-definition and cross references
  • include management
  • code formatting
  • simple refactorings

Setup

clangd server

clangd is a language server that must be installed separately, see getting started. The vscode-clangd extension will look for clangd on your PATH (you can change this in the settings).

Project setup

clangd is based on the clang C++ compiler, and understands even complex C++ code. However, you must tell clangd how your project is built (compile flags). A compile_commands.json file can usually be generated by your build system (e.g. by setting -DCMAKE_EXPORT_COMPILE_COMMANDS=1 when building with CMake, or with many other tools).

It should live at the top of your source tree: symlink or copy it there.

Features

Code completion

Suggestions will appear as you type names, or after . or ->. Because clangd uses a full C++ parser, code completion has access to precise type information.

Code completion

Errors, warnings, and clang-tidy

Code errors are shown as you type (both as red squiggle underlines, and in the "Problems" panel). These are the same as produced by the clang compiler, and suggested fixes can automatically be applied.

Error with fix

Most clang-tidy checks are supported (these can be enabled using a .clang-tidy file).

Cross-references

Go-to-definition and find-references work across your code, using a project-wide index.

Cross-reference list

Press Ctrl-P # to quickly navigate to a symbol by name.

Include management

Code completion works across your codebase and adds #include directives where needed. The shows includes that will be inserted.

clangd can also suggest inserting missing #includes, where they cause errors.

Fix inserts include

Formatting

clangd uses the clang-format engine. You can format a file or the selection. When "Format on Type" is enabled in the settings, pressing enter will cause clangd to format the old line and semantically reindent.

Format-on-type

The style used for formatting (and certain other operations) is controlled by the .clang-format file is controlled by the project's .clang-format file.

Refactoring

clangd supports some local refactorings. When you select an expression or declaration, the lightbulb menu appears and you can choose a code action.

Extract variable code action

Current refactorings include:

  • extract variable/function
  • expand auto types and macros
  • use raw strings
  • rename (bound to <F2>, rather than a contextual code action)

Bugs/contributing

clangd and vscode-clangd are part of the LLVM project.

If you'd like to help out, reach out to clangd-dev@lists.llvm.org.

If you've found a bug, please file at https://github.com/clangd/clangd/issues.