diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp --- a/clang-tools-extra/clangd/ClangdLSPServer.cpp +++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -571,7 +571,6 @@ {"referencesProvider", true}, {"astProvider", true}, // clangd extension {"typeHierarchyProvider", true}, - {"clangdInlayHintsProvider", true}, {"memoryUsageProvider", true}, // clangd extension {"compilationDatabase", // clangd extension llvm::json::Object{{"automaticReload", true}}}, @@ -608,6 +607,9 @@ if (Opts.FoldingRanges) ServerCaps["foldingRangeProvider"] = true; + if (Opts.InlayHints) + ServerCaps["clangdInlayHintsProvider"] = true; + std::vector Commands; for (llvm::StringRef Command : Handlers.CommandHandlers.keys()) Commands.push_back(Command); @@ -1477,7 +1479,8 @@ Bind.method("textDocument/documentLink", this, &ClangdLSPServer::onDocumentLink); Bind.method("textDocument/semanticTokens/full", this, &ClangdLSPServer::onSemanticTokens); Bind.method("textDocument/semanticTokens/full/delta", this, &ClangdLSPServer::onSemanticTokensDelta); - Bind.method("clangd/inlayHints", this, &ClangdLSPServer::onInlayHints); + if (Opts.InlayHints) + Bind.method("clangd/inlayHints", this, &ClangdLSPServer::onInlayHints); Bind.method("$/memoryUsage", this, &ClangdLSPServer::onMemoryUsage); if (Opts.FoldingRanges) Bind.method("textDocument/foldingRange", this, &ClangdLSPServer::onFoldingRange); diff --git a/clang-tools-extra/clangd/ClangdServer.h b/clang-tools-extra/clangd/ClangdServer.h --- a/clang-tools-extra/clangd/ClangdServer.h +++ b/clang-tools-extra/clangd/ClangdServer.h @@ -163,6 +163,9 @@ /// Enable preview of FoldingRanges feature. bool FoldingRanges = false; + /// Enable preview of InlayHints feature. + bool InlayHints = false; + FeatureModuleSet *FeatureModules = nullptr; explicit operator TUScheduler::Options() const; diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp --- a/clang-tools-extra/clangd/tool/ClangdMain.cpp +++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp @@ -307,6 +307,10 @@ Hidden, }; +opt InlayHints{"inlay-hints", cat(Features), + desc("Enable preview of InlayHints feature"), init(false), + Hidden}; + opt WorkerThreadsCount{ "j", cat(Misc), @@ -815,6 +819,7 @@ } Opts.AsyncThreadsCount = WorkerThreadsCount; Opts.FoldingRanges = FoldingRanges; + Opts.InlayHints = InlayHints; Opts.MemoryCleanup = getMemoryCleanupFunction(); Opts.CodeComplete.IncludeIneligibleResults = IncludeIneligibleResults;