summaryrefslogtreecommitdiffstats
path: root/source/kde/kde/patch/kate/361dd43e42994829dbdb35e78fb7698d27cbb0e2.patch
blob: 4f7237aaa4ed3cf8ab1fc86681782ed36f5173bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From 361dd43e42994829dbdb35e78fb7698d27cbb0e2 Mon Sep 17 00:00:00 2001
From: Mark Nauwelaerts <mark.nauwelaerts@gmail.com>
Date: Mon, 13 Dec 2021 20:52:57 +0100
Subject: [PATCH] lspclient: consider some additional server capabilities

---
 addons/lspclient/lspclientprotocol.h        | 14 +++++++++++++-
 addons/lspclient/lspclientserver.cpp        |  9 ++++++++-
 addons/lspclient/lspclientservermanager.cpp |  2 +-
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/addons/lspclient/lspclientprotocol.h b/addons/lspclient/lspclientprotocol.h
index 0fb7f4485..9de0ec511 100644
--- a/addons/lspclient/lspclientprotocol.h
+++ b/addons/lspclient/lspclientprotocol.h
@@ -21,6 +21,8 @@
 #include <KTextEditor/Cursor>
 #include <KTextEditor/Range>
 
+#include <optional>
+
 // Following types roughly follow the types/interfaces as defined in LSP protocol spec
 // although some deviation may arise where it has been deemed useful
 // Moreover, to avoid introducing a custom 'optional' type, absence of an optional
@@ -51,6 +53,16 @@ struct LSPResponseError {
 
 enum class LSPDocumentSyncKind { None = 0, Full = 1, Incremental = 2 };
 
+struct LSPSaveOptions {
+    bool includeText = false;
+};
+
+// only used parts for now
+struct LSPTextDocumentSyncOptions {
+    LSPDocumentSyncKind change = LSPDocumentSyncKind::None;
+    std::optional<LSPSaveOptions> save;
+};
+
 struct LSPCompletionOptions {
     bool provider = false;
     bool resolveProvider = false;
@@ -81,7 +93,7 @@ struct LSPWorkspaceFoldersServerCapabilities {
 };
 
 struct LSPServerCapabilities {
-    LSPDocumentSyncKind textDocumentSync = LSPDocumentSyncKind::None;
+    LSPTextDocumentSyncOptions textDocumentSync;
     bool hoverProvider = false;
     LSPCompletionOptions completionProvider;
     LSPSignatureHelpOptions signatureHelpProvider;
diff --git a/addons/lspclient/lspclientserver.cpp b/addons/lspclient/lspclientserver.cpp
index 8739d46c9..a7094fde2 100644
--- a/addons/lspclient/lspclientserver.cpp
+++ b/addons/lspclient/lspclientserver.cpp
@@ -344,8 +344,15 @@ static void from_json(LSPServerCapabilities &caps, const QJsonObject &json)
     };
 
     auto sync = json.value(QStringLiteral("textDocumentSync"));
-    caps.textDocumentSync = static_cast<LSPDocumentSyncKind>(
+    caps.textDocumentSync.change = static_cast<LSPDocumentSyncKind>(
         (sync.isObject() ? sync.toObject().value(QStringLiteral("change")) : sync).toInt(static_cast<int>(LSPDocumentSyncKind::None)));
+    if (sync.isObject()) {
+        auto syncObject = sync.toObject();
+        auto save = syncObject.value(QStringLiteral("save"));
+        if (save.isObject() || save.toBool()) {
+            caps.textDocumentSync.save = {save.toObject().value(QStringLiteral("includeText")).toBool()};
+        }
+    }
     caps.hoverProvider = toBoolOrObject(json.value(QStringLiteral("hoverProvider")));
     from_json(caps.completionProvider, json.value(QStringLiteral("completionProvider")));
     from_json(caps.signatureHelpProvider, json.value(QStringLiteral("signatureHelpProvider")));
diff --git a/addons/lspclient/lspclientservermanager.cpp b/addons/lspclient/lspclientservermanager.cpp
index 1fbcf928f..1e03801ea 100644
--- a/addons/lspclient/lspclientservermanager.cpp
+++ b/addons/lspclient/lspclientservermanager.cpp
@@ -931,7 +931,7 @@ private:
         auto it = m_docs.find(doc);
         if (it != m_docs.end() && it->server) {
             const auto &caps = it->server->capabilities();
-            if (caps.textDocumentSync == LSPDocumentSyncKind::Incremental) {
+            if (caps.textDocumentSync.change == LSPDocumentSyncKind::Incremental) {
                 return &(*it);
             }
         }
-- 
GitLab