[clangd] Enable folding ranges by default.

Differential Revision: https://reviews.llvm.org/D132919
This commit is contained in:
Utkarsh Saxena 2022-08-30 11:07:37 +02:00
parent 050dad57f7
commit c338735020
4 changed files with 5 additions and 16 deletions

View File

@ -584,6 +584,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
{"callHierarchyProvider", true},
{"clangdInlayHintsProvider", true},
{"inlayHintProvider", true},
{"foldingRangeProvider", true},
};
{
@ -613,8 +614,6 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
CodeAction::INFO_KIND}}}
: llvm::json::Value(true);
if (Opts.FoldingRanges)
ServerCaps["foldingRangeProvider"] = true;
std::vector<llvm::StringRef> Commands;
for (llvm::StringRef Command : Handlers.CommandHandlers.keys())
@ -1618,8 +1617,7 @@ void ClangdLSPServer::bindMethods(LSPBinder &Bind,
Bind.method("clangd/inlayHints", this, &ClangdLSPServer::onClangdInlayHints);
Bind.method("textDocument/inlayHint", this, &ClangdLSPServer::onInlayHint);
Bind.method("$/memoryUsage", this, &ClangdLSPServer::onMemoryUsage);
if (Opts.FoldingRanges)
Bind.method("textDocument/foldingRange", this, &ClangdLSPServer::onFoldingRange);
Bind.method("textDocument/foldingRange", this, &ClangdLSPServer::onFoldingRange);
Bind.command(ApplyFixCommand, this, &ClangdLSPServer::onCommandApplyEdit);
Bind.command(ApplyTweakCommand, this, &ClangdLSPServer::onCommandApplyTweak);

View File

@ -161,9 +161,6 @@ public:
/// fetch system include path.
std::vector<std::string> QueryDriverGlobs;
/// Enable preview of FoldingRanges feature.
bool FoldingRanges = false;
// Whether the client supports folding only complete lines.
bool LineFoldingOnly = false;

View File

@ -43,6 +43,7 @@
# CHECK-NEXT: "clangd.applyTweak"
# CHECK-NEXT: ]
# CHECK-NEXT: },
# CHECK-NEXT: "foldingRangeProvider": true,
# CHECK-NEXT: "hoverProvider": true,
# CHECK-NEXT: "implementationProvider": true,
# CHECK-NEXT: "inlayHintProvider": true,

View File

@ -308,6 +308,8 @@ RetiredFlag<bool> CollectMainFileRefs("collect-main-file-refs");
RetiredFlag<bool> CrossFileRename("cross-file-rename");
RetiredFlag<std::string> ClangTidyChecks("clang-tidy-checks");
RetiredFlag<std::string> InlayHints("inlay-hints");
RetiredFlag<std::string> FoldingRanges("folding-ranges");
opt<int> LimitResults{
"limit-results",
@ -333,14 +335,6 @@ list<std::string> TweakList{
CommaSeparated,
};
opt<bool> FoldingRanges{
"folding-ranges",
cat(Features),
desc("Enable preview of FoldingRanges feature"),
init(false),
Hidden,
};
opt<unsigned> WorkerThreadsCount{
"j",
cat(Misc),
@ -903,7 +897,6 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
Opts.StaticIndex = PAI.get();
}
Opts.AsyncThreadsCount = WorkerThreadsCount;
Opts.FoldingRanges = FoldingRanges;
Opts.MemoryCleanup = getMemoryCleanupFunction();
Opts.CodeComplete.IncludeIneligibleResults = IncludeIneligibleResults;