summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-24 12:29:51 -0500
committerpommicket <pommicket@gmail.com>2022-12-24 12:29:51 -0500
commita68d59e180b8131197c6387a764a78403b06e069 (patch)
tree53d32414fda2a4631a8476e766dcda8c0833c208
parente1b3296d7ecae1bf1620f53714ec3ba5b31709d4 (diff)
fix ted_get_lsp problem
-rw-r--r--buffer.c23
-rw-r--r--lsp.c4
-rw-r--r--main.c1
-rw-r--r--ted.c1
4 files changed, 15 insertions, 14 deletions
diff --git a/buffer.c b/buffer.c
index a8baa26..239dda3 100644
--- a/buffer.c
+++ b/buffer.c
@@ -2207,19 +2207,20 @@ Status buffer_load_file(TextBuffer *buffer, char const *filename) {
// can't write to this file; make the buffer view only.
buffer->view_only = true;
}
+
+ LSP *lsp = buffer_lsp(buffer);
+ if (lsp) {
+ // send didOpen
+ LSPRequest request = {.type = LSP_REQUEST_DID_OPEN};
+ LSPRequestDidOpen *open = &request.data.open;
+ open->file_contents = (char *)file_contents;
+ open->document = lsp_document_id(lsp, filename);
+ open->language = buffer_language(buffer);
+ lsp_send_request(lsp, &request);
+ file_contents = NULL; // don't free
+ }
}
- LSP *lsp = buffer_lsp(buffer);
- if (lsp) {
- // send didOpen
- LSPRequest request = {.type = LSP_REQUEST_DID_OPEN};
- LSPRequestDidOpen *open = &request.data.open;
- open->file_contents = (char *)file_contents;
- open->document = lsp_document_id(lsp, filename);
- open->language = buffer_language(buffer);
- lsp_send_request(lsp, &request);
- file_contents = NULL; // don't free
- }
}
free(file_contents);
diff --git a/lsp.c b/lsp.c
index 7aa4d56..3b91705 100644
--- a/lsp.c
+++ b/lsp.c
@@ -296,8 +296,8 @@ LSP *lsp_create(const char *root_dir, Language language, const char *analyzer_co
if (!lsp) return NULL;
#if DEBUG
- printf("Starting up LSP `%s` for language %s in %s\n",
- analyzer_command, language_to_str(language), root_dir);
+ printf("Starting up LSP %p `%s` for language %s in %s\n",
+ (void *)lsp, analyzer_command, language_to_str(language), root_dir);
#endif
ProcessSettings settings = {
diff --git a/main.c b/main.c
index 6cb5161..422b528 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,5 @@
/*
@TODO:
-- why arent we always sending didOpen?
- make sure "save as" works
- workspaceFolders support (so we don't need to start up multiple instances of rust-analyzer)
- more LSP stuff:
diff --git a/ted.c b/ted.c
index 3472a98..0a71227 100644
--- a/ted.c
+++ b/ted.c
@@ -111,6 +111,7 @@ LSP *ted_get_lsp(Ted *ted, const char *path, Language language) {
char *root_dir = settings_get_root_dir(settings, path);
ted->lsps[i] = lsp_create(root_dir, language, settings->lsp);
free(root_dir);
+ return ted->lsps[i];
}
return NULL;