diff options
author | pommicket <pommicket@gmail.com> | 2022-12-25 16:58:26 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-25 16:58:26 -0500 |
commit | 4bd6bbe54b291d8d65997e998a2a3946293adcdf (patch) | |
tree | 9951be5986187ec54531a7cb62fde90a48f9a559 | |
parent | 66a151badc6fb11b772c814ffcf2434e308923f2 (diff) |
set rootUri correctly
-rw-r--r-- | lsp-write.c | 21 | ||||
-rw-r--r-- | lsp.c | 16 | ||||
-rw-r--r-- | main.c | 6 | ||||
-rw-r--r-- | ted.cfg | 2 |
4 files changed, 29 insertions, 16 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); @@ -1,7 +1,7 @@ // print server-to-client communication #define LSP_SHOW_S2C 0 // print client-to-server communication -#define LSP_SHOW_C2S 1 +#define LSP_SHOW_C2S 0 #define write_bool lsp_write_bool @@ -306,6 +306,13 @@ LSP *lsp_create(const char *root_dir, Language language, const char *analyzer_co (void *)lsp, analyzer_command, language_to_str(language), root_dir); #endif + str_hash_table_create(&lsp->document_ids, sizeof(u32)); + strbuf_cpy(lsp->root_dir, root_dir); + lsp->language = language; + lsp->quit_sem = SDL_CreateSemaphore(0); + lsp->messages_mutex = SDL_CreateMutex(); + lsp->requests_mutex = SDL_CreateMutex(); + ProcessSettings settings = { .stdin_blocking = true, .stdout_blocking = false, @@ -320,13 +327,6 @@ LSP *lsp_create(const char *root_dir, Language language, const char *analyzer_co // immediately send the request rather than queueing it. // this is a small request, so it shouldn't be a problem. write_request(lsp, &initialize); - - str_hash_table_create(&lsp->document_ids, sizeof(u32)); - strbuf_cpy(lsp->root_dir, root_dir); - lsp->language = language; - lsp->quit_sem = SDL_CreateSemaphore(0); - lsp->messages_mutex = SDL_CreateMutex(); - lsp->requests_mutex = SDL_CreateMutex(); lsp->communication_thread = SDL_CreateThread(lsp_communication_thread, "LSP communicate", lsp); return lsp; } @@ -12,13 +12,15 @@ - delete old sent requests? but make sure requests that just take a long time are okay. (if the server never sends a response) - TESTING: make rust-analyzer-slow (waits 10s before sending response) -- rename buffer->filename to buffer->path - - make buffer->path NULL for untitled buffers & fix resulting mess - run everything through valgrind ideally with leak checking - grep -i -n TODO *.[ch] +--- LSP MERGE --- +- rename buffer->filename to buffer->path + - make buffer->path NULL for untitled buffers & fix resulting mess - rust-analyzer bug reports: - bad json can give "Unexpected error: client exited without proper shutdown sequence" FUTURE FEATURES: +- comment-start + comment-end settings - robust find (results shouldn't move around when you type things) - multiple files with command line arguments - configurable max buffer size + max view-only buffer size @@ -281,7 +281,7 @@ autocomplete-hl = #f6a3 # these control the text color for various kinds of completions autocomplete-variable = #bfb autocomplete-function = #aaf -autocomplete-type = #fac +autocomplete-type = #faf # Syntax highlighting |