[clang] [clang-tools-extra] [clangd] Show struct fields and enum members in hovers (PR #89557)

via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 22 09:16:01 PDT 2024


colin-grant-work wrote:

> As not all editors let you interact with hover cards, and just seeing a bunch of field names, without any extra info, sounds suboptimal to me... I'd like to have a way for such people to keep using hover cards without definition eating up the whole screen estate.

This basically raises the question of what the function of a hover is, and I don't think I'd like to limit its scope to just type annotation, with all other information available either only by triggering autocompletion (a bit of a workaround that may require extra typing, even if all you want to do is get an idea about how a struct is structured) or by jumping to the definition. ClangD's behavior is also a bit inconsistent.  In a hover, it will show documentation comments around the declaration, but not any of the content of the declaration. That means that it may eat up a lot of screen real estate if the documentation is extensive, but in the absence of documentation, it won't show much at all. Given that most terminal editors have either a gesture to show a hover or a gesture to dismiss one, or both, I'm not sure that avoiding using space for their sake really helps anybody.

Given those premises, I'd like to suggest aiming to figure out whether there is some useful data about structs / enums / (maybe even) classes / functions that ClangD can straightforwardly derive and (compactly) display, and if so, what that is. Allowing the behavior to be configured makes a lot of sense, perhaps both booleanly and scalarly, i.e. whether to display such data at all, and if so, the maximum amount that should be displayed, and in my view should address most concerns about its impact on particular editors.



https://github.com/llvm/llvm-project/pull/89557


More information about the cfe-commits mailing list