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 @@ -464,6 +464,16 @@ if (!Params.capabilities.RenamePrepareSupport) // Only boolean allowed per LSP RenameProvider = true; + // Per LSP, codeActionProvide can be either boolean or CodeActionOptions. + // CodeActionOptions is only valid if the client supports action liveral + // support (via textDocument.codeAction.codeActionLiteralSupport). + llvm::json::Value CodeActionProvider = true; + if (Params.capabilities.CodeActionStructure) + CodeActionProvider = llvm::json::Object{ + {"codeActionKinds", + {CodeAction::QUICKFIX_KIND, CodeAction::REFACTOR_KIND, + CodeAction::INFO_KIND}}}; + llvm::json::Object Result{ {{"capabilities", llvm::json::Object{ @@ -475,7 +485,7 @@ {"firstTriggerCharacter", "\n"}, {"moreTriggerCharacter", {}}, }}, - {"codeActionProvider", true}, + {"codeActionProvider", std::move(CodeActionProvider)}, {"completionProvider", llvm::json::Object{ {"resolveProvider", false},