Skip to content

Commit

Permalink
Add LSP initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
BojanStipic committed Apr 9, 2019
1 parent 845f48d commit fb0e147
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ void json_rpc(const cJSON *request) {
}
//const cJSON *params_json = cJSON_GetObjectItem(request, "params");

// RPC
if(strcmp(method, "initialize") == 0) {
lsp_initialize(id);
}
}

void lsp_send_response(int id, cJSON *result) {
Expand All @@ -90,3 +94,17 @@ void lsp_send_response(int id, cJSON *result) {
free(output);
cJSON_Delete(response);
}

// **************
// RPC functions:
// **************

void lsp_initialize(int id) {
cJSON *result = cJSON_CreateObject();
cJSON *capabilities = cJSON_CreateObject();
cJSON_AddNumberToObject(capabilities, "textDocumentSync", 1);
// TODO add other capabilities

cJSON_AddItemToObject(result, "capabilities", capabilities);
lsp_send_response(id, result);
}
10 changes: 10 additions & 0 deletions lsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@ void json_rpc(const cJSON *request);
*/
void lsp_send_response(int id, cJSON *result);

// **************
// RPC functions:
// **************

/*
* Parses LSP initialize request, and sends a response accordingly.
* Response specifies language server's capabilities.
*/
void lsp_initialize(int id);

#endif

0 comments on commit fb0e147

Please sign in to comment.