[clangd-dev] Disabling automatic insertion of include

Eric Liu via clangd-dev clangd-dev at lists.llvm.org
Tue Apr 9 12:01:10 PDT 2019

Sam has go/phab/D60409 ready to land. It will provide an option to disable
the automatic insertion.

Alternatively, clangd respects IWYU private pragma [0] which can be used by
library owners to specify alternative (public) include headers for index
symbols in private headers.


On Tue, Apr 9, 2019 at 8:50 PM Simon Marchi via clangd-dev <
clangd-dev at lists.llvm.org> wrote:

> Hi!
> In some cases, I find myself fighting against clangd automatically
> adding includes when choosing a completion item.  Is there a way to
> disable this feature?  If not, is there any opposition to adding one?
> One such example is when using glib.  The users of glib are supposed to
> only include glib.h, trying to include the more specific header files
> (such as glib/gscanner.h) results in an error:
> /usr/include/glib-2.0/glib/gscanner.h:29:2: error: #error "Only <glib.h>
> can be included directly."
>   #error "Only <glib.h> can be included directly."
>    ^~~~~
> When I choose a completion item, such as the GTokenType type, clangd
> automatically adds an include of "glib/gscanner.h", which I have to
> constantly remove before building.
> Ideally, this feature would always do the right thing in all situations,
> but since it's unlikely that clangd will ever be 100% right about this,
> I think it would be useful to be able to disable it.
> Thanks!
> Simon
> _______________________________________________
> clangd-dev mailing list
> clangd-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/clangd-dev/attachments/20190409/da69c331/attachment.html>

More information about the clangd-dev mailing list