summaryrefslogtreecommitdiff
path: root/ide-highlights.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-30 21:49:05 -0500
committerpommicket <pommicket@gmail.com>2022-12-30 21:49:05 -0500
commitf69275faee4cd3045389a98fefefb0c683757a5c (patch)
treec7b0e5cfe59205554e3b5fc5410d3bff9fe89599 /ide-highlights.c
parenta997d4106a397c785473bec5862c91bdf49f06ee (diff)
start document highlights
Diffstat (limited to 'ide-highlights.c')
-rw-r--r--ide-highlights.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/ide-highlights.c b/ide-highlights.c
new file mode 100644
index 0000000..4246c66
--- /dev/null
+++ b/ide-highlights.c
@@ -0,0 +1,32 @@
+void highlights_send_request(Ted *ted, TextBuffer *buffer) {
+ Highlights *hls = &ted->highlights;
+ if (!buffer) return;
+ LSP *lsp = buffer_lsp(buffer);
+ if (!lsp) return;
+ LSPDocumentPosition pos = buffer_cursor_pos_as_lsp_document_position(buffer);
+ LSPRequest request = {.type = LSP_REQUEST_HIGHLIGHT};
+ request.data.highlight.position = pos;
+ hls->last_request_id = lsp_send_request(lsp, &request);
+}
+
+void highlights_close(Ted *ted) {
+ arr_clear(ted->highlights.highlights);
+}
+
+void highlights_process_lsp_response(Ted *ted, LSPResponse *response) {
+ Highlights *hls = &ted->highlights;
+ if (response->request.type != LSP_REQUEST_HIGHLIGHT)
+ return; // not a highlight request
+ if (response->request.id != hls->last_request_id)
+ return; // old request
+ const LSPResponseHighlight *hl_response = &response->data.highlight;
+ arr_set_len(hls->highlights, arr_len(hl_response->highlights));
+ // type-safe memcpy
+ for (u32 i = 0; i < arr_len(hl_response->highlights); ++i)
+ hls->highlights[i] = hl_response->highlights[i];
+}
+
+void highlights_frame(Ted *ted) {
+ Highlights *hls = &ted->highlights;
+
+}