diff --git a/lsp.c b/lsp.c index e7b37d0..6c8b125 100644 --- a/lsp.c +++ b/lsp.c @@ -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) { @@ -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); +} diff --git a/lsp.h b/lsp.h index 64bf5cf..1e6aad3 100644 --- a/lsp.h +++ b/lsp.h @@ -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