@@ -251,19 +251,19 @@ opt<std::string> EnableFunctionArgSnippets{
251251 init (" -1" ),
252252};
253253
254- opt<CodeCompleteOptions::IncludeInsertion > HeaderInsertion{
254+ opt<Config::HeaderInsertionPolicy > HeaderInsertion{
255255 " header-insertion" ,
256256 cat (Features),
257257 desc (" Add #include directives when accepting code completions" ),
258258 init (CodeCompleteOptions ().InsertIncludes ),
259259 values (
260- clEnumValN (CodeCompleteOptions ::IWYU, " iwyu" ,
260+ clEnumValN (Config::HeaderInsertionPolicy ::IWYU, " iwyu" ,
261261 " Include what you use. "
262262 " Insert the owning header for top-level symbols, unless the "
263263 " header is already directly included or the symbol is "
264264 " forward-declared" ),
265265 clEnumValN (
266- CodeCompleteOptions ::NeverInsert, " never" ,
266+ Config::HeaderInsertionPolicy ::NeverInsert, " never" ,
267267 " Never insert #include directives as part of code completion" )),
268268};
269269
@@ -668,6 +668,7 @@ class FlagsConfigProvider : public config::Provider {
668668 std::optional<Config::ExternalIndexSpec> IndexSpec;
669669 std::optional<Config::BackgroundPolicy> BGPolicy;
670670 std::optional<Config::ArgumentListsPolicy> ArgumentLists;
671+ std::optional<Config::HeaderInsertionPolicy> HeaderInsertionPolicy;
671672
672673 // If --compile-commands-dir arg was invoked, check value and override
673674 // default path.
@@ -712,6 +713,11 @@ class FlagsConfigProvider : public config::Provider {
712713 BGPolicy = Config::BackgroundPolicy::Skip;
713714 }
714715
716+ // If CLI has set never, use that regardless of what the config files have
717+ if (HeaderInsertion == Config::HeaderInsertionPolicy::NeverInsert) {
718+ HeaderInsertionPolicy = Config::HeaderInsertionPolicy::NeverInsert;
719+ }
720+
715721 if (std::optional<bool > Enable = shouldEnableFunctionArgSnippets ()) {
716722 ArgumentLists = *Enable ? Config::ArgumentListsPolicy::FullPlaceholders
717723 : Config::ArgumentListsPolicy::Delimiters;
@@ -726,6 +732,8 @@ class FlagsConfigProvider : public config::Provider {
726732 C.Index .Background = *BGPolicy;
727733 if (ArgumentLists)
728734 C.Completion .ArgumentLists = *ArgumentLists;
735+ if (HeaderInsertionPolicy)
736+ C.Completion .HeaderInsertion = *HeaderInsertionPolicy;
729737 if (AllScopesCompletion.getNumOccurrences ())
730738 C.Completion .AllScopes = AllScopesCompletion;
731739
0 commit comments