1

Clangd doesn't suggest while I'm typing like 'shared' (I want std::shared_ptr suggested), unless the corresponding headers are included.
But in another project of mine, clangd works well. screen shot of the broken one

screen shot of the good one

I notice that only types miss in the broken one, functions in STL are suggested as expected. Configurations of clangd in this two projects are exactly the same.

configuration of the broken one

configuration of the good one

What I expect: While I'm typing like std::abc, clangd should suggest all possibilities in std matching abc.

user16217248
  • 3,119
  • 19
  • 19
  • 37
胡文浩
  • 13
  • 3

1 Answers1

0

The reason the behaviour varies from project to project is that the completions being offered depends on the symbols being present in the project's index, which will happen if any file in the project (not necessarily the one you're editing) includes the header defining them.

In clangd 15, a feature was added to get clangd to pro-actively index all the standard library headers (as if an invisible file in the project was including all of them). This can be enabled by adding the following to your clangd config file:

Index:
  StandardLibrary: Yes

In clangd 16, this feature will be enabled by default.

HighCommander4
  • 50,428
  • 24
  • 122
  • 194