ecode: Improve LSP code action implementation, now typescript-language-server will be able to recommend adding imports. Fixed a bug introduced in the previous commit, scrollTo for Y axis now moves correctly. Started implementing LSP Code Lens but I'll keep it for the moment since it's support in LSP implementations is very limited.

This commit is contained in:
Martín Lucas Golini
2023-07-07 01:01:26 -03:00
parent c6b308a118
commit ff7d8c3478
16 changed files with 302 additions and 95 deletions

View File

@@ -33,6 +33,7 @@ LSPDocumentClient::~LSPDocumentClient() {
void LSPDocumentClient::onDocumentLoaded( TextDocument* ) {
requestSemanticHighlightingDelayed();
// requestCodeLens();
}
void LSPDocumentClient::onDocumentTextChanged( const DocumentContentChange& change ) {
@@ -104,6 +105,7 @@ int LSPDocumentClient::getVersion() const {
void LSPDocumentClient::onServerInitialized() {
requestSymbols();
requestSemanticHighlighting();
// requestCodeLens();
}
void LSPDocumentClient::refreshTag() {
@@ -178,6 +180,21 @@ bool LSPDocumentClient::isWaitingSemanticTokensResponse() const {
return mWaitingSemanticTokensResponse;
}
void LSPDocumentClient::requestCodeLens() {
if ( !mServer || !mServer->getCapabilities().codeLensProvider.supported )
return;
URI uri = mDoc->getURI();
LSPClientServer* server = mServer;
LSPDocumentClient* docClient = this;
mServer->documentCodeLens(
uri, [uri, server, docClient]( const auto&, const std::vector<LSPCodeLens>& codeLens ) {
if ( server->hasDocument( uri ) ) {
docClient->mCodeLens = codeLens;
}
} );
}
UISceneNode* LSPDocumentClient::getUISceneNode() {
LSPClientServer* server = mServer;
if ( !server || !server->getManager() || !server->getManager()->getPluginManager() ||