summaryrefslogtreecommitdiff
path: root/src/lsp/json_rpc.c
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-11 17:16:40 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-11 17:17:04 +0000
commitd2461482caf9e93d6e2bc7ff17567102f635211a (patch)
treec302d1a2e7cb829b6ed006c905db0b8bbf45f57a /src/lsp/json_rpc.c
parentf9b1992795142a073cd5dc1794350fc64e9aa695 (diff)
Fixed some things. Next thing will be tests.
Diffstat (limited to 'src/lsp/json_rpc.c')
-rw-r--r--src/lsp/json_rpc.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lsp/json_rpc.c b/src/lsp/json_rpc.c
index 008a147..903da71 100644
--- a/src/lsp/json_rpc.c
+++ b/src/lsp/json_rpc.c
@@ -1,8 +1,8 @@
+#include "json_rpc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "json_rpc.h"
// Basic JSON parsing helpers
char *get_json_string(const char *json, const char *key)
@@ -27,8 +27,9 @@ char *get_json_string(const char *json, const char *key)
return res;
}
-// Extract nested "text" from params/contentChanges/0/text or params/textDocument/text
-// This is very hacky for MVP. proper JSON library needed.
+// Extract nested "text" from params/contentChanges/0/text or
+// params/textDocument/text This is very hacky for MVP. proper JSON library
+// needed.
char *get_text_content(const char *json)
{
@@ -116,10 +117,11 @@ void handle_request(const char *json_str)
{
if (strstr(json_str, "\"method\":\"initialize\""))
{
- const char *response =
- "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"capabilities\":{\"textDocumentSync\":1,"
- "\"definitionProvider\":true,\"hoverProvider\":true,\"completionProvider\":{"
- "\"triggerCharacters\":[\".\"]}}}}";
+ const char *response = "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{"
+ "\"capabilities\":{\"textDocumentSync\":1,"
+ "\"definitionProvider\":true,\"hoverProvider\":true,"
+ "\"completionProvider\":{"
+ "\"triggerCharacters\":[\".\"]}}}}";
fprintf(stdout, "Content-Length: %ld\r\n\r\n%s", strlen(response), response);
fflush(stdout);
return;