From 6205e83793eff547d404fa5bde747076a1191893 Mon Sep 17 00:00:00 2001 From: pommicket Date: Thu, 22 Dec 2022 18:19:02 -0500 Subject: didClose notification, better completion --- lsp-write-request.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lsp-write-request.c') diff --git a/lsp-write-request.c b/lsp-write-request.c index f375559..28b19d3 100644 --- a/lsp-write-request.c +++ b/lsp-write-request.c @@ -77,7 +77,7 @@ static void write_arr_elem(JSONWriter *o) { static void write_escaped(JSONWriter *o, const char *string) { StrBuilder *b = &o->builder; size_t output_index = str_builder_len(b); - size_t capacity = 2 * strlen(string) + 1; + size_t capacity = 2 * strlen(string) + 1; // append a bunch of null bytes which will hold the escaped string str_builder_append_null(b, capacity); char *out = str_builder_get_ptr(b, output_index); @@ -181,6 +181,8 @@ static const char *lsp_request_method(LSPRequest *request) { return "initialized"; case LSP_REQUEST_DID_OPEN: return "textDocument/didOpen"; + case LSP_REQUEST_DID_CLOSE: + return "textDocument/didClose"; case LSP_REQUEST_DID_CHANGE: return "textDocument/didChange"; case LSP_REQUEST_COMPLETION: @@ -200,6 +202,7 @@ static bool request_type_is_notification(LSPRequestType type) { case LSP_REQUEST_INITIALIZED: case LSP_REQUEST_EXIT: case LSP_REQUEST_DID_OPEN: + case LSP_REQUEST_DID_CLOSE: case LSP_REQUEST_DID_CHANGE: return true; case LSP_REQUEST_INITIALIZE: @@ -264,6 +267,14 @@ static void write_request(LSP *lsp, LSPRequest *request) { write_obj_end(o); write_obj_end(o); } break; + case LSP_REQUEST_DID_CLOSE: { + const LSPRequestDidClose *close = &request->data.close; + write_key_obj_start(o, "params"); + write_key_obj_start(o, "textDocument"); + write_key_file_uri(o, "uri", close->document); + write_obj_end(o); + write_obj_end(o); + } break; case LSP_REQUEST_DID_CHANGE: { LSPRequestDidChange *change = &request->data.change; static unsigned long long version_number = 1; // @TODO @TEMPORARY -- cgit v1.2.3