diff options
author | pommicket <pommicket@gmail.com> | 2022-12-29 23:13:23 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-29 23:13:23 -0500 |
commit | a0f8332da674d452f7ae4f84f01d4682d464c9b2 (patch) | |
tree | d003832a43f92b8b466815dc3f1354e5b69da11d /lsp.c | |
parent | adbfd5f248d390ae73eb9da636a457ce770c9ac0 (diff) |
show the wait cursor when waiting for go to definition
Diffstat (limited to 'lsp.c')
-rw-r--r-- | lsp.c | 40 |
1 files changed, 37 insertions, 3 deletions
@@ -162,15 +162,48 @@ void lsp_send_message(LSP *lsp, LSPMessage *message) { SDL_UnlockMutex(lsp->messages_mutex); } -bool lsp_send_request(LSP *lsp, LSPRequest *request) { +static bool request_type_is_notification(LSPRequestType type) { + switch (type) { + case LSP_REQUEST_NONE: break; + case LSP_REQUEST_INITIALIZED: + case LSP_REQUEST_EXIT: + case LSP_REQUEST_DID_OPEN: + case LSP_REQUEST_DID_CLOSE: + case LSP_REQUEST_DID_CHANGE: + case LSP_REQUEST_DID_CHANGE_WORKSPACE_FOLDERS: + case LSP_REQUEST_JDTLS_CONFIGURATION: + return true; + case LSP_REQUEST_INITIALIZE: + case LSP_REQUEST_SHUTDOWN: + case LSP_REQUEST_SHOW_MESSAGE: + case LSP_REQUEST_LOG_MESSAGE: + case LSP_REQUEST_COMPLETION: + case LSP_REQUEST_SIGNATURE_HELP: + case LSP_REQUEST_HOVER: + case LSP_REQUEST_DEFINITION: + case LSP_REQUEST_WORKSPACE_FOLDERS: + return false; + } + assert(0); + return false; +} + +LSPRequestID lsp_send_request(LSP *lsp, LSPRequest *request) { if (!lsp_supports_request(lsp, request)) { lsp_request_free(request); - return false; + return 0; + } + + bool is_notification = request_type_is_notification(request->type); + LSPRequestID id = 0; + if (!is_notification) { + id = ++lsp->request_id; + request->id = id; } LSPMessage message = {.type = LSP_REQUEST}; message.u.request = *request; lsp_send_message(lsp, &message); - return true; + return id; } void lsp_send_response(LSP *lsp, LSPResponse *response) { @@ -395,6 +428,7 @@ LSP *lsp_create(const char *root_dir, Language language, const char *analyzer_co LSPRequest initialize = { .type = LSP_REQUEST_INITIALIZE }; + initialize.id = ++lsp->request_id; // immediately send the request rather than queueing it. // this is a small request, so it shouldn't be a problem. write_request(lsp, &initialize); |