#include "../libs/cjson/cJSON.h"
#include "node.h"
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <termios.h>
#include <unistd.h>

void start_lsp(const char *cmd, char *const argv[]);
void lsp_send(cJSON *msg);
cJSON *lsp_recv();
cJSON *make_fold_request(int id, const char *uri);
cJSON *make_open_file_request(const char *uri, const char *languageId,
                              const char *text, int version);
cJSON *make_folder_init_request(int id, const char *root_uri);
cJSON *make_change_file_request(const char *uri, int version, size_t start_line,
                                size_t start_col, size_t end_line,
                                size_t end_col, const char *new_text);
cJSON *make_hover_request(int id, const char *uri, size_t line,
                          size_t character);
void lsp_setup(Node *buffer, uint8_t lang);
void lsp_change(Node *buffer, size_t start_line, size_t start_col,
                size_t end_line, size_t end_col, const char *new_text);
void lsp_hover(Node *buffer, size_t line, size_t character);
