Hover
Symbol Information
Qualified name showing enclosing scope context (namespace, class)
Symbol kind classification
Access specifier (public / protected / private)
Documentation comments (Doxygen)
Source definition rendering
Truncate large initializers in definition display (clangd#710)
cppconst int table[] = {0, 1, 2, /* ... 1000 elements ... */}; // hover → show truncated definition, not the entire initializerShow
virtual/override/finalmodifiers in hover (clangd#2474)cppstruct Base { virtual void draw() = 0; }; struct Circle : Base { void draw() override; // hover should show "virtual void draw() override" };Show anonymous namespace in scope display (clangd#436)
cppnamespace { void helper(); } // hover on helper → scope: "(anonymous namespace)::"
Type Information
Variable type with pretty-printing
Desugared type (
akafield) for type aliasesReturn type for functions/lambdas
Function parameters with types, names, defaults
Template parameters
Deduced type on
autoanddecltypekeyword hoverShow deduced template arguments for CTAD variables (clangd#435)
cppstd::pair p(1, 3.14); // hover on p → "std::pair<int, double> p"Show template arguments for instantiations (clangd#230)
cpptemplate<typename T> T identity(T x) { return x; } identity(42); // hover → show "T = int" in template parametersResolve lambda
autoparameter types from call context (clangd#493)cppauto cmp = [](auto a, auto b) { return a < b; }; std::sort(v.begin(), v.end(), cmp); // hover on a → "int" (deduced from std::sort<int>)Preserve sugared types for
autovariables (clangd#709)cppauto it = vec.begin(); // current: "auto it" → "__gnu_cxx::__normal_iterator<int*, ...>" // expected: "auto it" → "std::vector<int>::iterator"Apply
.clang-formatstyle to printed type names (clangd#2156)cpp// .clang-format: QualifierAlignment: Right const int* p; // current: hover → "const int *p" // expected: hover → "int const *p"Correct hover for C typedef of anonymous struct (clangd#2219)
cpptypedef struct { int x, y; } Point; Point p; // current: hover → "struct Point p" (misleading — no struct Point exists) // expected: hover → "Point p" (alias to anonymous struct)Concept and constrained
autohover showing constraint information
Layout Information
Size (bits) for fields and types
Offset within enclosing class
Padding detection
Alignment
Show alignment and padding for type-level hover, not just fields (clangd#1763)
cppstruct Widget { int id; // offset 0, size 32 double value; // offset 64, size 64, padding 32 }; // hover on Widget → size: 128 bits, align: 64 bits, padding: 32 bits totalVirtual function table offset for class methods (clangd#1771)
cppstruct Base { virtual void foo(); // hover → vtable offset: 0 virtual void bar(); // hover → vtable offset: 1 };
Expression Context
Evaluated constant value (
valuefield)Callee argument info (which parameter this maps to)
Pass-by semantics (ref, const ref, value)
Implicit conversion detection
Show string literal length on hover (clangd#1016)
cppconst char* msg = "hello world"; // ^^^^^^^^^^^^^ hover → length: 11 (excluding null terminator)Show numeric literal type on hover (clangd#1669)
cppauto x = 42ULL; // ^^^^^ hover → type: unsigned long long, value: 42 auto y = 0x1p10; // ^^^^^^ hover → type: double, value: 1024.0Avoid misleading expression value when hovering over record-type variables (clangd#1622)
cppconstexpr int N = 10; std::array<int, N> arr; arr[0]; // hover on arr → should NOT show "value: 10" from enclosing expression
Documentation
Resolve
@copydocDoxygen tags (clangd#1320)cpp/// Detailed documentation. void base_func(); /// @copydoc base_func() void wrapper(); // hover on wrapper → show base_func's documentationInherit documentation from overridden base methods (clangd#2504)
cppstruct Base { /// Renders the widget. virtual void draw(); }; struct Circle : Base { void draw() override; // hover → "Renders the widget." (inherited from Base::draw) };Share documentation across consecutive overloads (clangd#2506)
cpp/// Opens a file. void open(const char* path); void open(const char* path, int flags); // hover on second overload → "Opens a file." (shared from first)Documentation from inherited constructors (clangd#1936)
Only associate comments directly above the declaration (clangd#974)
cpp// ==== Section Banner ==== void foo(); // hover on foo → should NOT show "==== Section Banner ===="Option to suppress misattributed doc comments (clangd#2148)
Prefer declaration documentation over definition comments (clangd#829)
cpp// header.h: /// Public API documentation. void process(int x); // source.cpp: // internal implementation note void process(int x) { ... } // hover → show "Public API documentation.", not "internal implementation note"Preserve whitespace and newlines from comments (clangd#2057)
cpp/// | Column A | Column B | /// |----------|----------| /// | 1 | 2 | void table_fn(); // hover → render the markdown table correctly, not as a single lineFix wrong indentation in hover comment rendering (clangd#1040)
Docstrings missing when template keyword comes from macro expansion (clangd#1226)
Synthesized documentation for trivial accessors (getters/setters)
Macro Hover
Show macro expansion before definition (clangd#2642)
cpp#define MAX(a, b) ((a) > (b) ? (a) : (b)) int z = MAX(x, y); // ^^^^^^^^^ hover → expansion: "((x) > (y) ? (x) : (y))" // definition: "#define MAX(a, b) ((a) > (b) ? (a) : (b))"
Special Hover Targets
Show struct/enum members on type-level hover (clangd#959)
cppenum Color { Red, Green, Blue }; // hover on Color → "enum Color { Red, Green, Blue }"Show underlying struct definition for typedef (clangd#2020)
cpptypedef struct { int x, y; } Point; Point p; // hover on Point → show the struct definition including membersKeyword documentation on hover (clangd#1862)
cppconst int x = 42; // hover on "const" → description of the keywordAttribute documentation on hover (clangd#1862)
cpp[[nodiscard]] int compute(); // hover on "nodiscard" → description of the attribute#includedirective hover showing resolved header paththisexpression hover showing pointed-to type__func__and related predefined identifier hoverGTK-Doc, kernel-doc, and GObject Introspection documentation (clangd#2662)
LaTeX rendering of Doxygen
@f$math formulas (clangd#2669)
Module-Related
- Hover on
importstatement shows module info - Hover on module name shows owning file/partition list
Hover Correctness
Known issues that should be handled correctly:
-
MSInheritanceAttrcausing incorrect hover on MSVC targets (clangd#1643, clangd#2212) - Object instantiation misidentified as function declaration (clangd#2225)
- Crash on large unsigned enum constant value (clangd#2381)
- Crash on function call hover with default arguments (clangd#551)
- Symbols shadowed by function-like macros with the same name (clangd#2490)
Changelog
| Date | Change | PR |
|---|---|---|
| 2025-06 | Port clangd hover implementation | #452 |