Skip to content

Commit

Permalink
Add LSP shutdown and exit
Browse files Browse the repository at this point in the history
  • Loading branch information
BojanStipic committed Apr 9, 2019
1 parent fb0e147 commit 3f6edb6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ void json_rpc(const cJSON *request) {
if(strcmp(method, "initialize") == 0) {
lsp_initialize(id);
}
else if(strcmp(method, "shutdown") == 0) {
lsp_shutdown(id);
}
else if(strcmp(method, "exit") == 0) {
lsp_exit();
}
}

void lsp_send_response(int id, cJSON *result) {
Expand Down Expand Up @@ -108,3 +114,11 @@ void lsp_initialize(int id) {
cJSON_AddItemToObject(result, "capabilities", capabilities);
lsp_send_response(id, result);
}

void lsp_shutdown(int id) {
lsp_send_response(id, NULL);
}

void lsp_exit() {
exit(0);
}
8 changes: 8 additions & 0 deletions lsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,13 @@ void lsp_send_response(int id, cJSON *result);
* Response specifies language server's capabilities.
*/
void lsp_initialize(int id);
/*
* Parses LSP shutdown request, and sends a response.
*/
void lsp_shutdown(int id);
/*
* Stops the language server.
*/
void lsp_exit();

#endif

0 comments on commit 3f6edb6

Please sign in to comment.