[clang-tools-extra] [clangd] Make clangd-indexer respect .clangd configuration files (PR #214951)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 31 23:04:28 PDT 2026
================
@@ -152,6 +166,17 @@ int main(int argc, const char **argv) {
return 1;
}
+ clang::clangd::RealThreadsafeFS TFS;
+ std::vector<std::unique_ptr<clang::clangd::config::Provider>> ProviderStack;
+ if (clang::clangd::EnableConfig)
+ ProviderStack =
+ clang::clangd::config::Provider::createDefaultProviders(TFS);
+ auto ConfigProvider =
+ clang::clangd::config::Provider::combineOwned(std::move(ProviderStack));
+ auto ContextProvider =
+ clang::clangd::ClangdServer::createConfiguredContextProvider(
----------------
HighCommander4 wrote:
Passing `Callbacks=nullptr` here means that diagnostics encountered while parsing the config file will be silently dropped.
As mentioned [in the Discourse thread](https://discourse.llvm.org/t/honor-clangd-compileflags-overrides-in-clangd-indexer/91504/3?u=highcommander4), I think the behaviour we'd want here is to print the diagnostics to the terminal.
There are two ways we could accomplish this:
* Give the indexer its own `ClangdServer::Callbacks` implementation and pass that to `ClangdServer::createConfiguredcontextProvider` here
* Give the indexer its own (simpler) "create context provider from config provider" function and use that instead of `ClangdServer::createConfiguredContextProvider`
Not sure which one is less hassle (maybe the latter).
https://github.com/llvm/llvm-project/pull/214951
More information about the cfe-commits
mailing list