Skip to content

Commit

Permalink
[clangd] Hide inlay hints capability behind a command-line flag
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D101275
  • Loading branch information
HighCommander4 committed May 3, 2021
1 parent 43cbf2b commit cea736e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion clang-tools-extra/clangd/ClangdLSPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
{"referencesProvider", true},
{"astProvider", true}, // clangd extension
{"typeHierarchyProvider", true},
{"clangdInlayHintsProvider", true},
{"memoryUsageProvider", true}, // clangd extension
{"compilationDatabase", // clangd extension
llvm::json::Object{{"automaticReload", true}}},
Expand Down Expand Up @@ -608,6 +607,9 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
if (Opts.FoldingRanges)
ServerCaps["foldingRangeProvider"] = true;

if (Opts.InlayHints)
ServerCaps["clangdInlayHintsProvider"] = true;

std::vector<llvm::StringRef> Commands;
for (llvm::StringRef Command : Handlers.CommandHandlers.keys())
Commands.push_back(Command);
Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/clangd/ClangdLSPServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class ClangdLSPServer : private ClangdServer::Callbacks,
std::function<bool(const Tweak &)> TweakFilter = [](const Tweak &T) {
return !T.hidden(); // only enable non-hidden tweaks.
};

/// Enable preview of InlayHints feature.
bool InlayHints = false;
};

ClangdLSPServer(Transport &Transp, const ThreadsafeFS &TFS,
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/clangd/tool/ClangdMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ opt<bool> FoldingRanges{
Hidden,
};

opt<bool> InlayHints{"inlay-hints", cat(Features),
desc("Enable preview of InlayHints feature"), init(false)};

opt<unsigned> WorkerThreadsCount{
"j",
cat(Misc),
Expand Down Expand Up @@ -829,6 +832,7 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
}
Opts.AsyncThreadsCount = WorkerThreadsCount;
Opts.FoldingRanges = FoldingRanges;
Opts.InlayHints = InlayHints;
Opts.MemoryCleanup = getMemoryCleanupFunction();

Opts.CodeComplete.IncludeIneligibleResults = IncludeIneligibleResults;
Expand Down

0 comments on commit cea736e

Please sign in to comment.