[clang-tools-extra] 2a095ff - [clangd] Add add commit characters to the server capabilities
Kirill Bobyrev via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 18 23:33:17 PST 2020
Author: Kirill Bobyrev
Date: 2020-02-19T08:32:00+01:00
New Revision: 2a095ff6f5028b7612dae50358a2f6939b6cdc9f
URL: https://github.com/llvm/llvm-project/commit/2a095ff6f5028b7612dae50358a2f6939b6cdc9f
DIFF: https://github.com/llvm/llvm-project/commit/2a095ff6f5028b7612dae50358a2f6939b6cdc9f.diff
LOG: [clangd] Add add commit characters to the server capabilities
Summary:
Make it more convinient for the clients to select completion items by
providing a set of default characters (punctuation).
Related issue: https://github.com/clangd/clangd/issues/284
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D74606
Added:
Modified:
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/test/initialize-params.test
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 93609a8852db..c31a0a417ebe 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -559,6 +559,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
{"codeActionProvider", std::move(CodeActionProvider)},
{"completionProvider",
llvm::json::Object{
+ {"allCommitCharacters", " \t()[]{}<>:;,+-/*%^&#?.=\"'|"},
{"resolveProvider", false},
// We do extra checks for '>' and ':' in completion to only
// trigger on '->' and '::'.
diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h
index 80a11ee00307..a376e5f39e79 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -1101,6 +1101,8 @@ struct CompletionItem {
/// the client side.
float score = 0.f;
+ // TODO: Add custom commitCharacters for some of the completion items. For
+ // example, it makes sense to use () only for the functions.
// TODO(krasimir): The following optional fields defined by the language
// server protocol are unsupported:
//
diff --git a/clang-tools-extra/clangd/test/initialize-params.test b/clang-tools-extra/clangd/test/initialize-params.test
index e5ec9fb3d7ac..8984f36db7d0 100644
--- a/clang-tools-extra/clangd/test/initialize-params.test
+++ b/clang-tools-extra/clangd/test/initialize-params.test
@@ -7,6 +7,7 @@
# CHECK-NEXT: "capabilities": {
# CHECK-NEXT: "codeActionProvider": true,
# CHECK-NEXT: "completionProvider": {
+# CHECK-NEXT: "allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"",
# CHECK-NEXT: "resolveProvider": false,
# CHECK-NEXT: "triggerCharacters": [
# CHECK-NEXT: ".",
More information about the cfe-commits
mailing list