On Wed, Jan 15, 2025 at 2:21 PM Peter Eisentraut <pe...@eisentraut.org> wrote: > I have committed this. Thanks for the feedback.
Thanks for working on this. Is it worth documenting how to get clangd working sensibly with "--header-insertion=iwyu"? I enabled it just now. I find that I can now use completion with a type name, and have clangd automatically include the necessary header file. For example, if I use completion to pull in a "StringInfoData" I find that clangd will automatically add the necessary #include "lib/stringinfo.h", without any special directions from me -- no context switching required. Importantly, now that we have these annotations, clangd won't constantly be adding useless includes that actually come from c.h -- that made IWYU header cleaning unusable before now. Note that I'm relying on my clang-tidy config for this. clangd is able to respect our conventions around headers through clang-tidy, which has been taught Postgres-specific rules around header conventions. So we'd actually be documenting something about clang-tidy + clangd + Postgres header conventions, if we went through with something like this. It might be worth holding off for now. It's possible that I'll find --header-insertion=iwyu has big problems in some unforeseen way. But offhand it looks like a real improvement, even though I foresee certain minor downsides. What do you think? -- Peter Geoghegan