diff --git a/src/clang_complete.cc b/src/clang_complete.cc index cc15089a..39bc03c8 100644 --- a/src/clang_complete.cc +++ b/src/clang_complete.cc @@ -612,7 +612,7 @@ void DiagnosticQueryMain(ClangCompleteManager *manager) { // Fetching the completion request blocks until we have a request. ClangCompleteManager::DiagnosticRequest request = manager->diagnostic_request_.Dequeue(); - if (!g_config->diagnostics.onType) + if (!g_config->diagnostics.onChange) continue; std::string path = request.document.uri.GetPath(); diff --git a/src/config.h b/src/config.h index c22a99f8..3e22a0e9 100644 --- a/src/config.h +++ b/src/config.h @@ -59,6 +59,9 @@ struct Config { SerializeFormat cacheFormat = SerializeFormat::Binary; struct Clang { + // Arguments that should be excluded, e.g. ["-fopenmp", "-Wall"] + std::vector excludeArgs; + // Additional arguments to pass to clang. std::vector extraArgs; @@ -149,11 +152,11 @@ struct Config { // xxx: at most every xxx milliseconds int frequencyMs = 0; - // If true, diagnostics will be reported in textDocument/didOpen. - bool onOpen = true; + // If true, diagnostics will be reported for textDocument/didChange. + bool onChange = true; - // If true, diagnostics from typing will be reported. - bool onType = true; + // If true, diagnostics will be reported for textDocument/didOpen. + bool onOpen = true; std::vector whitelist; } diagnostics; @@ -231,15 +234,15 @@ struct Config { int maxNum = 2000; } xref; }; -MAKE_REFLECT_STRUCT(Config::Clang, extraArgs, resourceDir); +MAKE_REFLECT_STRUCT(Config::Clang, excludeArgs, extraArgs, resourceDir); MAKE_REFLECT_STRUCT(Config::ClientCapability, snippetSupport); MAKE_REFLECT_STRUCT(Config::CodeLens, localVariables); MAKE_REFLECT_STRUCT(Config::Completion, caseSensitivity, dropOldRequests, detailedLabel, filterAndSort, includeBlacklist, includeMaxPathSize, includeSuffixWhitelist, includeWhitelist); -MAKE_REFLECT_STRUCT(Config::Diagnostics, blacklist, frequencyMs, onOpen, - onType, whitelist) +MAKE_REFLECT_STRUCT(Config::Diagnostics, blacklist, frequencyMs, onChange, + onOpen, whitelist) MAKE_REFLECT_STRUCT(Config::Highlight, lsRanges, blacklist, whitelist) MAKE_REFLECT_STRUCT(Config::Index, blacklist, comments, enabled, multiVersion, multiVersionBlacklist, multiVersionWhitelist, onDidChange, diff --git a/src/project.cc b/src/project.cc index d7d6e3a5..c25e97c9 100644 --- a/src/project.cc +++ b/src/project.cc @@ -32,6 +32,7 @@ using namespace ccls; #include #include #include +#include #include #include using namespace clang; @@ -96,7 +97,7 @@ struct ProjectProcessor { args.push_back(arg.substr(5)); } else if (arg == "%clang") { args.push_back(lang == LanguageId::Cpp ? "clang++" : "clang"); - } else { + } else if (!llvm::is_contained(g_config->clang.excludeArgs, arg)) { args.push_back(arg); } }