LinuxCommandLibrary

clangd

C/C++ language server for IDE features

TLDR

Start clangd language server

$ clangd
copy
Start with specific compile commands database
$ clangd --compile-commands-dir=[/path/to/build]
copy
Enable more inlay hints
$ clangd --inlay-hints
copy
Start with background indexing
$ clangd --background-index
copy
Limit memory usage
$ clangd --malloc-trim --pch-storage=memory
copy
Enable verbose logging
$ clangd --log=verbose
copy
Check version
$ clangd --version
copy

SYNOPSIS

clangd [options]

DESCRIPTION

clangd is a C/C++/Objective-C language server that provides IDE features like code completion, diagnostics, go-to-definition, and refactoring for editors supporting the Language Server Protocol (LSP).
It uses the clang compiler frontend for parsing and understanding code, providing accurate results based on real compilation. clangd reads compilecommands.json or compileflags.txt to understand project build settings.
The server communicates over stdin/stdout using JSON-RPC, making it compatible with VS Code, Vim, Emacs, Sublime Text, and other LSP-capable editors.

PARAMETERS

--compile-commands-dir= dir

Directory containing compile_commands.json.
--background-index
Build an index in the background.
--clang-tidy
Enable clang-tidy diagnostics.
--completion-style= style
Style of completion (detailed, bundled).
--header-insertion= mode
Auto-include headers (iwyu, never).
--inlay-hints
Enable inlay hints.
--log= level
Log level (error, info, verbose).
--pch-storage= type
PCH storage (disk, memory).
--query-driver= paths
Allow system includes from compilers.
-j threads
Number of worker threads.
--enable-config
Enable .clangd configuration files.
--version
Display version information.

CONFIGURATION

.clangd

Project-level configuration for compiler flags, diagnostics, and completion behavior.
compile_commands.json
Build system-generated compilation database for accurate project analysis.
compile_flags.txt
Simple per-line compiler flags as an alternative to compile_commands.json.

CAVEATS

Requires compilecommands.json or compileflags.txt for accurate analysis. Initial indexing can be slow for large projects. Memory usage scales with project size. Some features require recent clangd versions. May not find system headers without proper configuration.

HISTORY

clangd was developed as part of the LLVM/Clang project starting around 2017 to provide a modern language server for C-family languages. It replaced earlier tools like libclang-based completers. The project has seen rapid development, with features like semantic highlighting, inlay hints, and improved indexing added over time. It's now considered one of the most capable C++ language servers.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

$169.99
KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

$16.99
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

$1,589.00
Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

$169.99
New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

$54.00