[clangd-dev] Disabling automatic insertion of include

Simon Marchi via clangd-dev clangd-dev at lists.llvm.org
Tue Apr 9 11:49:57 PDT 2019


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.



More information about the clangd-dev mailing list