Setting up LSP with clangd

Background

Editors such as Emacs, Vim, or VS Code support features like code navigation, code completion, inline compiler error messages, and others, through LSP, the Language Server Protocol. A common language server with LSP support is clangd, which relies on the presence of compile_commands.json, a JSON file with a record of the compile commands for each file in a project.

How do I generate compile_commands.json for XLA source code?

Use the build_tools/lint/generate_compile_commands.py script. The following invocation from XLA repo root generates a compile_commands.json file in place: bazel aquery "mnemonic(CppCompile, //xla/...)" --output=jsonproto | python3 build_tools/lint/generate_compile_commands.py

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024年11月05日 UTC.