Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
f932b667
Commit
f932b667
authored
Dec 13, 2021
by
Mark Nauwelaerts
Browse files
lspclient: consider some additional server capabilities
parent
eb5956e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
addons/lspclient/lspclientprotocol.h
View file @
f932b667
...
...
@@ -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
{
LSPDocumentSync
Kind
textDocumentSync
=
LSPDocumentSyncKind
::
None
;
LSP
Text
DocumentSync
Options
textDocumentSync
;
bool
hoverProvider
=
false
;
LSPCompletionOptions
completionProvider
;
LSPSignatureHelpOptions
signatureHelpProvider
;
...
...
addons/lspclient/lspclientserver.cpp
View file @
f932b667
...
...
@@ -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"
)));
...
...
addons/lspclient/lspclientservermanager.cpp
View file @
f932b667
...
...
@@ -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
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment