diff options
author | pommicket <pommicket@gmail.com> | 2023-08-04 19:35:48 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-08-04 19:35:48 -0400 |
commit | 45d69107725a02cf6d912a571b771da3ef5abfbf (patch) | |
tree | 6b5d44104f57074dc00f1bab8eed986ca707b8a2 /ide-document-link.c | |
parent | f278b832dc6e085d05b243bbae2af82e78e36d6d (diff) |
textDocument/documentLink parsing
Diffstat (limited to 'ide-document-link.c')
-rw-r--r-- | ide-document-link.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/ide-document-link.c b/ide-document-link.c new file mode 100644 index 0000000..d0e1ef8 --- /dev/null +++ b/ide-document-link.c @@ -0,0 +1,49 @@ +#include "ted.h" + +void document_link_frame(Ted *ted) { + DocumentLink *document_link = &ted->document_link; + + bool key_down = ted_is_ctrl_down(ted); + if (!key_down) { + document_link->key_press_time = 0.0; + } else if (document_link->key_press_time == 0.0) { + document_link->key_press_time = ted->frame_time; + } + + bool show_links = document_link->key_press_time != 0.0 + && ted->frame_time - document_link->key_press_time > 1.0; + + if (!show_links) { + ted_cancel_lsp_request(ted, &document_link->last_request); + return; + } + + TextBuffer *buffer = ted->active_buffer; + if (!buffer) + return; + + LSP *lsp = buffer_lsp(buffer); + if (!lsp) + return; + + if (!document_link->last_request.id) { + // send the request + LSPRequest request = {.type = LSP_REQUEST_DOCUMENT_LINK}; + LSPRequestDocumentLink *lnk = &request.data.document_link; + lnk->document = buffer_lsp_document_id(buffer); + document_link->last_request = lsp_send_request(lsp, &request); + } +} + +void document_link_process_lsp_response(Ted *ted, const LSPResponse *response) { + if (response->request.type != LSP_REQUEST_DOCUMENT_LINK) + return; + + (void)ted;//TODO + const LSPResponseDocumentLink *document_link = &response->data.document_link; + + arr_foreach_ptr(document_link->links, const LSPDocumentLink, link) { + printf("target: %s\n", lsp_response_string(response, link->target)); + + } +} |