mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-15 21:45:14 +03:00
Some snippets improvements to support insertTextFormat (SpartanJ/ecode/discussions#929).
Closes SpartanJ/ecode#933
This commit is contained in:
@@ -86,6 +86,7 @@ static const char* MEMBER_SUCCESS = "success";
|
||||
static const char* MEMBER_LIMIT = "limit";
|
||||
static const char* MEMBER_OPTIONS = "options";
|
||||
static const char* MEMBER_PREVIOUS_RESULT_IDS = "previousResultIds";
|
||||
static const char* MEMBER_INSERT_TEXT_FORMAT = "insertTextFormat";
|
||||
|
||||
static json newRequest( const std::string& method, const json& params = json{} ) {
|
||||
json j;
|
||||
@@ -885,9 +886,11 @@ static LSPCompletionList parseDocumentCompletion( const json& result ) {
|
||||
item.contains( "additionalTextEdits" )
|
||||
? parseTextEditArray( item.at( "additionalTextEdits" ) )
|
||||
: std::vector<LSPTextEdit>{};
|
||||
|
||||
ret.items.push_back( { label, kind, detail, doc, sortText, insertText, filterText,
|
||||
textEdit, additionalTextEdits } );
|
||||
auto itf = item.value( MEMBER_INSERT_TEXT_FORMAT, 1 );
|
||||
LSPInsertTextFormat insertTextFormat =
|
||||
itf == 2 ? LSPInsertTextFormat::Snippet : LSPInsertTextFormat::PlainText;
|
||||
ret.items.push_back( { label, kind, detail, doc, sortText, insertText, insertTextFormat,
|
||||
filterText, textEdit, additionalTextEdits } );
|
||||
}
|
||||
#ifndef EE_DEBUG
|
||||
} catch ( const json::exception& err ) {
|
||||
|
||||
@@ -531,6 +531,11 @@ class LSPCompletionItemHelper {
|
||||
}
|
||||
};
|
||||
|
||||
enum class LSPInsertTextFormat {
|
||||
PlainText = 1,
|
||||
Snippet = 2,
|
||||
};
|
||||
|
||||
struct LSPCompletionItem {
|
||||
std::string label;
|
||||
LSPCompletionItemKind kind;
|
||||
@@ -538,6 +543,7 @@ struct LSPCompletionItem {
|
||||
LSPMarkupContent documentation;
|
||||
std::string sortText;
|
||||
std::string insertText;
|
||||
LSPInsertTextFormat insertTextFormat{ LSPInsertTextFormat::PlainText };
|
||||
std::string filterText;
|
||||
LSPTextEdit textEdit;
|
||||
std::vector<LSPTextEdit> additionalTextEdits;
|
||||
|
||||
Reference in New Issue
Block a user