summaryrefslogtreecommitdiff
path: root/lsp-write.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-25 16:58:26 -0500
committerpommicket <pommicket@gmail.com>2022-12-25 16:58:26 -0500
commit4bd6bbe54b291d8d65997e998a2a3946293adcdf (patch)
tree9951be5986187ec54531a7cb62fde90a48f9a559 /lsp-write.c
parent66a151badc6fb11b772c814ffcf2434e308923f2 (diff)
set rootUri correctly
Diffstat (limited to 'lsp-write.c')
-rw-r--r--lsp-write.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/lsp-write.c b/lsp-write.c
index ef524d9..b66def9 100644
--- a/lsp-write.c
+++ b/lsp-write.c
@@ -167,6 +167,12 @@ static void write_arr_elem_string(JSONWriter *o, const char *s) {
write_string(o, s);
}
+static void write_file_uri_direct(JSONWriter *o, const char *path) {
+ str_builder_append(&o->builder, "\"file://");
+ write_escaped(o, path);
+ str_builder_append(&o->builder, "\"");
+}
+
static void write_file_uri(JSONWriter *o, LSPDocumentID document) {
if (document >= arr_len(o->lsp->document_data)) {
assert(0);
@@ -174,9 +180,7 @@ static void write_file_uri(JSONWriter *o, LSPDocumentID document) {
return;
}
const char *path = o->lsp->document_data[document].path;
- str_builder_append(&o->builder, "\"file:///");
- write_escaped(o, path);
- str_builder_append(&o->builder, "\"");
+ write_file_uri_direct(o, path);
}
static void write_key_file_uri(JSONWriter *o, const char *key, LSPDocumentID document) {
@@ -184,6 +188,11 @@ static void write_key_file_uri(JSONWriter *o, const char *key, LSPDocumentID doc
write_file_uri(o, document);
}
+static void write_key_file_uri_direct(JSONWriter *o, const char *key, const char *path) {
+ write_key(o, key);
+ write_file_uri_direct(o, path);
+}
+
static void write_position(JSONWriter *o, LSPPosition position) {
write_obj_start(o);
write_key_number(o, "line", (double)position.line);
@@ -327,8 +336,10 @@ static void write_request(LSP *lsp, LSPRequest *request) {
write_obj_end(o);
write_obj_end(o);
write_obj_end(o);
- write_key_null(o, "rootUri");
- write_key_null(o, "workspaceFolders");
+ write_key_file_uri_direct(o, "rootUri", lsp->root_dir);
+// write_key_arr_start(o, "workspaceFolders");
+// write_arr_elem_obj_start(o);
+// write_arr_end(o);
write_key_obj_start(o, "clientInfo");
write_key_string(o, "name", "ted");
write_obj_end(o);